How to set multiple fields as uniqueKey in solr?

陌路散爱 提交于 2019-11-27 07:53:48

问题


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


回答1:


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 use generate a concatenated field of the values you want into a single unique string before indexing.



来源:https://stackoverflow.com/questions/24454755/how-to-set-multiple-fields-as-uniquekey-in-solr

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!