java - Solr Composite Unique key from existing fields in schema -


i have index named locationindex in solr fields follows:

<fields>     <field name="solr_id" type="string" stored="true" required="true" indexed="true"/>     <field name="solr_ver" type="string" stored="true" required="true" indexed="true" default="0000"/>     // , more fields </fields> <uniquekey>solr_id</uniquekey> 

but want change schema unique key must composite of 2 present fields solr_id , solr_ver... follows:

<fields>     <field name="solr_id" type="string" stored="true" required="true" indexed="true"/>     <field name="solr_ver" type="string" stored="true" required="true" indexed="true" default="0000"/>     <field name="composite-id" type="string" stored="true" required="true" indexed="true"/>     // , more fields </fields> <uniquekey>solr_ver-solr_id</uniquekey> 

after searching found it's possible adding following schema: (ref: solr composite unique key existing fields in schema)

<updaterequestprocessorchain name="composite-id">   <processor class="solr.clonefieldupdateprocessorfactory">     <str name="source">docid_s</str>     <str name="source">userid_s</str>     <str name="dest">id</str>   </processor>   <processor class="solr.concatfieldupdateprocessorfactory">     <str name="fieldname">id</str>     <str name="delimiter">--</str>   </processor>   <processor class="solr.logupdateprocessorfactory" />   <processor class="solr.runupdateprocessorfactory" /> </updaterequestprocessorchain> 

so changed schema , looks like:

<updaterequestprocessorchain name="composite-id">   <processor class="solr.clonefieldupdateprocessorfactory">     <str name="source">solr_ver</str>     <str name="source">solr_id</str>     <str name="dest">id</str>   </processor>   <processor class="solr.concatfieldupdateprocessorfactory">     <str name="fieldname">id</str>     <str name="delimiter">-</str>   </processor>   <processor class="solr.logupdateprocessorfactory" />   <processor class="solr.runupdateprocessorfactory" /> </updaterequestprocessorchain>  <fields>     <field name="solr_id" type="string" stored="true" required="true" indexed="true"/>     <field name="solr_ver" type="string" stored="true" required="true" indexed="true" default="0000"/>     <field name="id" type="string" stored="true" required="true" indexed="true"/>     // , more fields </fields> <uniquekey>id</uniquekey> 

but while adding document it's giving me error:

org.apache.solr.client.solrj.solrserverexception: server @ http://localhost:8983/solr/locationindex returned non ok status:400, message:document [null] missing required field: id 

i'm not getting changes in schema required work desired?

in document add, contain fields solr_ver , solr_id. how , it'll (solr) create id field combining both these field solr_ver-solr_id?

edit:

at this link it's given how refer chain. bu i'm unable understand how used in schema? , should make changes?

so looks have updaterequestprocessorchain defined appropriately , should work. however, need add solrconfig.xml file , not schema.xml. additional link provided shows how modify solrconfig.xml file , add defined updaterequestprocessorchain current /update request handler solr instance.

so find following:

  1. move <updaterequestprocessorchain> solrconfig.xml file.
  2. update <requesthandler name="/update" class="solr.updaterequesthandler"> entry in solrconfig.xml file , modify looks following:

    <requesthandler name="/update" class="solr.updaterequesthandler">    <lst name="defaults">       <str name="update.chain">composite-id</str>    </lst> </requesthandler> 

this should execute defined update chain , populate id field when new documents added index.


Comments

Popular posts from this blog

ruby on rails - Permission denied @ sys_fail2 - (D:/RoR/projects/grp/public/uploads/ -

c++ - nodejs socket.io closes connection before upgrading to websocket -

python - PyQt: Label not showing correct number of length -