Note that there are some explanatory texts on larger screens.

plurals
  1. POHow do I get Lucene.NET to combine 2 Sitecore fields in to 1 index field?
    primarykey
    data
    text
    <p>I am using Lucene.NET with Sitecore for searching. I have created a custom Lucene index. Normally it is a one-to-one mapping between Sitecore fields and Lucene index fields. I would like to be able to take 2 fields and combine them in the Lucene index. Below is an example of my custom index definition. You will see a field called Activity and a field called Board. Then below it is an example of what I am trying to do - combine Activity and Board in to one field in the index. I just am not sure if this is possible and if so, what the syntax is for defining a combined field like this. Any ideas?</p> <pre><code> &lt;index id="reportsIndex" singleInstance="true" type="IOM.library.CustomIndexer, IOM"&gt; &lt;param desc="name"&gt;$(id)&lt;/param&gt; &lt;template hint="list:AddTemplate"&gt; &lt;template&gt;{79EBE484-BAD6-4173-B80A-29AC7D734565}&lt;/template&gt; &lt;/template&gt; &lt;fields hint="raw:AddField"&gt; &lt;field target="Title"&gt;Title&lt;/field&gt; &lt;field target="SortTitle" storage="keyword"&gt;Title&lt;/field&gt; &lt;field target="ShortDescription"&gt;ShortDescription&lt;/field&gt; &lt;field target="FullDescription"&gt;FullDescription&lt;/field&gt; &lt;field target="Topic"&gt;Topic&lt;/field&gt; &lt;field target="Type"&gt;Type&lt;/field&gt; &lt;field target="ReleaseDate"&gt;ReleaseDate&lt;/field&gt; &lt;field target="Series"&gt;Series&lt;/field&gt; &lt;field target="Activity"&gt;Activity&lt;/field&gt; &lt;field target="Board"&gt;Board&lt;/field&gt; &lt;field target="MyCombinedField"&gt;??Activity, Board??&lt;/field&gt; &lt;/fields&gt; &lt;/index&gt; </code></pre> <p>UPDATE: I tried to do what people have suggested and map 2 different Sitecore fields to the same Lucene field. However that doesn't seem to work. I tried the following:</p> <pre><code>&lt;index id="reportsIndex" singleInstance="true" type="IOM.library.CustomIndexer, IOM"&gt; &lt;param desc="name"&gt;$(id)&lt;/param&gt; &lt;template hint="list:AddTemplate"&gt; &lt;template&gt;{79EBE484-BAD6-4173-B80A-29AC7D734565}&lt;/template&gt; &lt;/template&gt; &lt;fields hint="raw:AddField"&gt; &lt;field target="Title"&gt;Title&lt;/field&gt; &lt;field target="Activity"&gt;Activity&lt;/field&gt; &lt;field target="Board"&gt;Board&lt;/field&gt; &lt;field target="MyCombinedField"&gt;Activity&lt;/field&gt; &lt;field target="MyCombinedField"&gt;Board&lt;/field&gt; &lt;/fields&gt; &lt;/index&gt; </code></pre> <p>When I look in IndexViewer this is what I see. If the content item has content for the Activity field then that will get populated in the "MyCombinedField" (since it is first). If the Activity field has no content then Lucene will populate the "MyCombinedField" with the Board content. But it never puts both field's content in to the MyCombinedField field. Am I doing something wrong?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload