Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
290 views
in Technique[技术] by (71.8m points)

solrj - Configuring Solr to use UUID as a key

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

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...