Configuring Solr to use UUID as a key

懵懂的女人 提交于 2019-12-29 09:04:03

问题


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


回答1:


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>



回答2:


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.



来源:https://stackoverflow.com/questions/18698651/configuring-solr-to-use-uuid-as-a-key

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!