【问题标题】:Query two multivalued fields in solr在solr中查询两个多值字段
【发布时间】:2012-09-12 05:57:46
【问题描述】:

我有一个关于 solr 查询的问题,它有两个多值字段。 流它是架构的一部分:

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

问题是查询条件“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”时才能返回文档,我该怎么做?

谢谢!

【问题讨论】:

  • 我不认为你可以用多值字段做到这一点。我想你需要为你的问题分开字段

标签: java apache solr


【解决方案1】:

Christian Lendel 建议的选项可行,另一个选项是加入 attributelocale 选项并将其索引为一个字符串:“en_US this is english description” . 然后就可以这样查询了:

q=attribute:(english en_US)

解决方案可能更简单或更复杂,取决于您想要实现的目标。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-12-26
    • 2013-06-18
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多