5

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 Parsing Failed: unknown field '(Id,IdCategory,Rank,TypeRank)'. Schema file is /var/solr/Rank/schema.xml

Abdelali AHBIB
  • 602
  • 1
  • 7
  • 18

1 Answers1

10

You cannot use 2 or 3 (or 4) fields in a unique key in the way you are trying to do it. It should point to a single string field. You should be able to generate a concatenated field of the values you want into a single unique string before indexing.

MattMcKnight
  • 8,185
  • 28
  • 35
  • This did not work for me. I get the error `uniqueKey field can not be the dest of a copyField` – jakraska Oct 20 '14 at 19:14
  • I think that was fixed in version 4.0? https://issues.apache.org/jira/browse/SOLR-2796 – MattMcKnight Oct 21 '14 at 00:12
  • It wasn't "Fixed" in 4.0 - the ability to do this was removed. Moving forward you have to use the updateRequestProcessorChain in your solrconfig.xml https://wiki.apache.org/solr/Deduplication – jakraska Oct 21 '14 at 20:52
  • ah, makes sense this would be hard with sharding on uniquekey in cloud. I generate the value before sending to solr, so haven't hit this yet. – MattMcKnight Oct 22 '14 at 03:23