Java 查询solr中的两个多值字段
我有一个关于solr查询的问题,它有两个多值字段。 Fllow它是模式的一部分:Java 查询solr中的两个多值字段,java,apache,solr,Java,Apache,Solr,我有一个关于solr查询的问题,它有两个多值字段。 Fllow它是模式的一部分: <field name="attribute" type="text" indexed="true" stored="true" multiValued="true"/> <field name="locale" type="text" indexed="true" stored="true" multiValued="true"/> 它从xml中读取数据: <docs>
<field name="attribute" type="text" indexed="true" stored="true" multiValued="true"/>
<field name="locale" type="text" indexed="true" stored="true" multiValued="true"/>
它从xml中读取数据:
<docs>
<doc>
<id>01000</id>
<name>product1</name>
<price>102.5</price>
<attributes name="description">
<str attribute="this is english description" locale="en_US" />
<str attribute="this is chinese description" locale="zh_CN" />
</attributes>
</doc>
</docs>
01000
产品1
102.5
问题在于,查询条件“q=attribute:english AND locale:en_US”或“q=attribute:english AND locale:zh_CN”都可以返回此文档
我希望只有当条件为“q=attribute:english AND locale:en_US”或“q=attribute:chinese AND locale:zh_CN”时才能返回文档,我该怎么做
谢谢大家! Christian Lendel建议的选项可行,另一个选项是连接属性和区域设置选项,并将其索引为一个字符串:“en_US,这是英文描述”。 然后您可以这样查询:
q=attribute:(english en_US)
解决方案可能更简单,也可能更复杂,这取决于您想要实现什么。我认为对于多值字段,您无法做到这一点。我想您需要为您的问题分离字段