Solr Composite Unikalny klucz z istniejących pól w schemacie
Mam indeks o nazwieLocationIndex
w solr z polami w następujący sposób:
<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"/>
// and some more fields
</fields>
<uniqueKey>solr_id</uniqueKey>
Ale teraz chcę zmienić schemat, aby unikalny klucz był złożony z dwóch już istniejących pólsolr_id
isolr_ver
... coś w następujący sposób:
<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"/>
// and some more fields
</fields>
<uniqueKey>solr_ver-solr_id</uniqueKey>
Po przeszukaniu odkryłem, że jest to możliwe, dodając następujące elementy do schematu: (ref:Solr Composite Unikalny klucz z istniejących pól w schemacie)
<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>
Zmieniłem schemat i na koniec wygląda to tak:
<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"/>
// and some more fields
</fields>
<uniqueKey>id</uniqueKey>
Ale podczas dodawania dokumentu to daje mi błąd:
org.apache.solr.client.solrj.SolrServerException: Server at http://localhost:8983/solr/LocationIndex returned non ok status:400, message:Document [null] missing required field: id
Nie rozumiem, jakie zmiany w schemacie są wymagane do pracy zgodnie z oczekiwaniami?
W dodawanym dokumencie zawiera polasolr_ver
isolr_id
. Jak i gdzie będzie (solr) tworzyćid
pole łącząc oba te polasolr_ver-solr_id
?
EDYTOWAĆ:
Wten link Podano, jak odnoszą się do tego łańcucha. Bu Nie jestem w stanie zrozumieć, w jaki sposób byłby używany w schemacie? A gdzie powinienem dokonać zmian?