mam indeksu o nazwie LocationIndex
w Solr z pola w następujący sposób:Solr Composite unikalny klucz z istniejących pól w schemacie
<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 tak, że unikalny klucz musi być złożony z dwóch już obecny Pola solr_id
i solr_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 poszukiwaniach znalazłem, że jest to możliwe poprzez dodanie następujących do schematu: (ref: Solr Composite Unique key from 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>
Więc zmieniłem schemat i wreszcie to wygląda:
<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
ja nie dostaję, jakie zmiany w schemacie są wymagane do pracy zgodnie z życzeniem?
W dokumencie, który dodaję, zawiera pola solr_ver
i solr_id
. Jak i gdzie to będzie (solr) utworzyć pole id
, łącząc oba te pola, takie jak solr_ver-solr_id
?
EDIT:
Na this link To biorąc pod uwagę jak odnoszą się do tego łańcucha. Bu Nie jestem w stanie zrozumieć, w jaki sposób będzie on stosowany w schemacie? I gdzie powinienem dokonać zmian?
możesz opublikować plik db-data.config – Nipun