2012-09-12 38 views
0

我有一个关于solr查询的问题,它有两个多值字段。 Fllow它是架构的一部分:查询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 =属性:英语和语言环境:EN_US” 或“Q =属性:英文和区域设置:zh_CN“可以返回此文档。

我希望只有当条件是“q = attribute:english AND locale:en_US”或“q = attribute:chinese AND locale:zh_CN”才能返回文档,我该怎么办?

谢谢!

+1

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

回答

1

基督教Lendel建议将工作的选项,其他选项将加入属性区域期权和指数它作为一个字符串:“EN_US这是英文说明”。 然后你就可以查询就是这样:

q=attribute:(english en_US) 

解决方案可能是更简单或更复杂,取决于你想要达到的目标。