I have been playing with solr for about a week now. My issue is probably a rare case related to highlighting as I was not able to find a solution here on SO or anywhere on the Internet.
I have enabled highlighting and almost everything works fine – I get the search results and the parts that are highlighted are returned in <lst name="highlighting">.
The problem is, none of the child nodes that actually contain the highlighted part of text have the name attribute, which is supposed to be the same as the id attribute of the respective result item.
Below is an extract from the result returned from search using the solr admin.
<result name="response" numFound="121" start="0" maxScore="2.3798883">
<doc>
<float name="score">2.3798883</float>
<str name="Turn">Android Linux</str>
<str name="id">dcc190ba-143b-4fb7-b868-ef06875210fe</str>
<float name="startTime">961.98</float>
</doc>
<doc>
<float name="score">1.009701</float>
<str name="Turn">
ci sono per� degli aspetti diversi perch� Microsoft vendeva windows mentre l' Ugl regala Android che quindi la licenza Android non costa nulla
</str>
<str name="id">804df3fb-3709-4bf8-a0d0-718dc5da18f1</str>
<float name="startTime">2445.19</float>
</doc>
</result>
<lst name="highlighting">
<lst>
<arr name="Turn">
<str><span class="highlight">Android</span> Linux</str>
</arr>
</lst>
<lst>
<arr name="Turn">
<str>ci sono per degli aspetti diversi perch Microsoft vendeva windows mentre l' Ugl regala <span class="highlight">Android</span>
</str>
</arr>
</lst>
<lst>
<arr name="Turn">
<str><span class="highlight">Android</span> nd Kappa e l' ambiente che ci permette di scrivere in codice in attivo
</str>
</arr>
</lst>
</lst>
As can be seen, the id attribute is there for each result. It’s just that it is not used in the nodes.
I am using uuid type for the id which is generated automatically by solr.
Here’s part of my schema.xml file.
<field name="id" type="uuid" indexed="true" stored="true" required="true" default="NEW"/>
<field name="startTime" type="float" indexed="true" stored="true" />
<field name="Turn" type="text_general" indexed="true" stored="true"/>
The fieldType uuid is defined in the schema.xml file as below:
<fieldType name="uuid" class="solr.UUIDField" indexed="true" />
And below is the update processor that generates the id (in solrconfig.xml):
<updateRequestProcessorChain name="uuid">
<processor class="solr.processor.SignatureUpdateProcessorFactory">
<bool name="enabled">true</bool>
<str name="signatureField">id</str>
<bool name="overwriteDupes">false</bool>
<str name="fields">*</str>
<str name="signatureClass">solr.processor.Lookup3Signature</str>
</processor>
<processor class="solr.LogUpdateProcessorFactory" />
<processor class="solr.RunUpdateProcessorFactory" />
</updateRequestProcessorChain>
Without the id as value of the name attribute inside an item, I won’t be able to do further processing, such as replacing text in the result.
I hope this info is enough. Please let me know otherwise. I’ve been trying to get to the bottom of this for two days now.
Cheers.
In another desperate attempt to get it working, I replaced my solrconfig.xml file with the original, put back in only the specific changes I had done, and the problem was gone. I’m sure the problem can be tracked to a few specific lines as I must have added something in there during the first few days of my practice that was messing it all up for me.