4

I am trying to configure Solr 4 to work with UUID and so far I am unsuccessful

From reading the documentation I have seen two different ways to configure schema.xml to work with UUID (both do not work)

for both I need to write

<fieldType name="uuid" class="solr.UUIDField" indexed="true" />

option 1: add:

<field name="id" type="uuid" indexed="true" stored="true" default="NEW" multiValued="false"/>

and make sure to remove the line

<uniqueKey>id</uniqueKey>

option 2 add:

<field name="id" type="uuid" indexed="true" stored="true" required="true" multiValued="false" /> 

Both options are not working correctly and returning org.apache.solr.common.SolrException:org.apache.solr.common.SolrException: Error initializing QueryElevationComponent.

I also tried adding a row to the colrconfig.xml file with the configuration:

<updateRequestProcessorChain name="uuid">
<processor class="solr.UUIDUpdateProcessorFactory"> 
    <str name="fieldName">uniqueKey</str> 
</processor>    
<processor class="solr.RunUpdateProcessorFactory" />
</updateRequestProcessorChain>

Thanks,

Shimon

Shimon Benattar
  • 173
  • 1
  • 3
  • 9
  • Does your basic setup work without trying to change the type of the id field? The QueryElevationComponent error sounds like it could be a general config problem – Kieran Sep 09 '13 at 13:43
  • yes it works, when setting id to string all is well – Shimon Benattar Sep 09 '13 at 15:37
  • possible duplicate of [Solr 4 - missing required field: uuid](http://stackoverflow.com/questions/16914324/solr-4-missing-required-field-uuid) – Seb D. Mar 17 '15 at 13:49

2 Answers2

8

After some work here is the solution:

In schema.xml, add (or edit) the field field

<field name="id" type="string" indexed="true" stored="true" required="true" multiValued="false" />   

In solr config, update the chain and add the chain to the handlers (Example: for /update/extract):

<updateRequestProcessorChain name="uuid">
  <processor class="solr.UUIDUpdateProcessorFactory">
    <str name="fieldName">id</str>
  </processor>
  <processor class="solr.RunUpdateProcessorFactory" />
</updateRequestProcessorChain>`         

<requestHandler name="/update/extract" 
                startup="lazy"
                class="solr.extraction.ExtractingRequestHandler" >
  <lst name="defaults">
    <str name="lowernames">true</str>
    <str name="uprefix">ignored_</str>
    <str name="captureAttr">true</str>
    <str name="fmap.a">links</str>
    <str name="fmap.div">ignored_</str>
    <str name="update.chain">uuid</str>
  </lst>
</requestHandler>
Martin Valgur
  • 5,793
  • 1
  • 33
  • 45
Shimon Benattar
  • 173
  • 1
  • 3
  • 9
  • you may also add a query parameter "&update.chain=uuid" to your update query URL in order to trigger the UUID generation without need to define a custom request handler – Jan Rasehorn Feb 15 '22 at 16:44
-1

You may want to remove the Query Elevation component if not using it.

QueryElevationComponent requires unique key to be defined and it should be a string unique key with JIRA.

However, it was fixed with the Solr 4.0 alpha so it would depend what Solr version you are using.

This limitation is documented in the Solr wiki.

Jayendra
  • 52,349
  • 4
  • 80
  • 90
  • Hi Jayendra thanks for your reply. I am using the latest version of Solr 4.4.0. Also, from what I understand concerning QueryElevationComponent I can disable it when querying but my problem is that when I define the field id as uuid the core will not load. Anyway, adding UUId support seems to me to be a basic operation that I would like to add without removing any components. – Shimon Benattar Sep 10 '13 at 06:41
  • you would need to remove query elevation component and as disabling it would not work as it depends on the unique key. – Jayendra Sep 10 '13 at 06:49