How to set multiple fields as uniqueKey in solr?

I have these fields in my solr schema:

<fields>
    <field name="Id" type="string" indexed="true" stored="true" multiValued="false" required="true" />
    <field name="IdCategory" type="string" indexed="true" stored="true" multiValued="false" required="true" />
    <field name="Rank" type="long" indexed="true" stored="true" multiValued="false" required="true" />
    <field name="TypeRank" type="string" indexed="true" stored="true" multiValued="false" required="false" default="category" />

    <field name="_version_" type="long" indexed="true" stored="true"/>
</fields>

Can I use 2 or 3 fields as uniqueKeys instead of One? When I try:

<uniqueKey>(Id,IdCategory,Rank,TypeRank)</uniqueKey>

I get the following error:

org.apache.solr.common.SolrException: org.apache.solr.common.SolrException: schema analysis failed: unknown field '(Id, IdCategory, Rank, TypeRank)'. Schema file - / var / solr / Rank / schema.xml

+4
source share
1 answer

You cannot use 2 or 3 (or 4) fields in a unique key in the form that you are trying to do. It must point to a single field in a row. You should be able to use the generated concatenated field of the values ​​you want in one unique row before indexing.

+6

Source: https://habr.com/ru/post/1546322/


All Articles