如何在solr中将多个字段设置为uniqueKey? [英] How to set multiple fields as uniqueKey in solr?

查看:63
本文介绍了如何在solr中将多个字段设置为uniqueKey?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的 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>

我可以使用 2 或 3 个字段作为唯一键而不是一个吗?当我尝试:

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

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

我收到以下错误:

org.apache.solr.common.SolrException:org.apache.solr.common.SolrException: 模式解析失败: 未知字段 '(Id,IdCategory,Rank,TypeRank)'.架构文件是/var/solr/Rank/schema.xml

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

推荐答案

您不能以尝试的方式在唯一键中使用 2 或 3(或 4)个字段.它应该指向单个字符串字段.您应该能够在索引之前将您想要的值的串联字段生成为单个唯一字符串.

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.

这篇关于如何在solr中将多个字段设置为uniqueKey?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆