solr查询多个字段的语法

时间:2014-02-20 09:22:11

标签: solr solrj solr-query-syntax

我有一个看起来像这样的文件:

<date name="added">2014-02-17T17:17:01Z</date>
<arr name="authorids"><str>57373</str></arr>
<str name="body">German chancellor Angela Merkel has proposed some stuff, well done her.</str>
<str name="contentid">9</str>
<arr name="countryids"><str>37,38,119</str><str/><str/></arr>
<str name="excerpt">German chancellor Angela Merkel has proposed setting upsome stuff that will do really well.</str>
<str name="key">146</str>
<str name="layoutid">1</str>
<date name="modified">2014-02-17T17:17:05Z</date>
<date name="published">2014-02-17T17:17:00Z</date>
<str name="shortcut">1</str>
<str name="sitecode">GIR</str>
<str name="statusid">5</str>
<str name="title">Merkel backs separate EU internet infrastructure</str>
<str name="uid">146</str>
<str name="url">http://127.0.0.1:84/something/123/edit/</str>

当我通过查询参数传递给solr:

q=statusid:5 AND (title:"Merkel" OR body:"Merkel" OR excerpt:"Merkel") AND sitecode:GIR

哪个应该匹配上面的文件,我没有得到任何结果,我不明白为什么。 solr文档似乎很清楚如何正确查询solr。

我的文档架构如下所示:

 <fields>
   <field name="key"        type="string" indexed="false" stored="true" required="true" />
   <field name="url"        type="string" indexed="false" stored="true" required="false" />
   <field name="sitecode"   type="string" indexed="true" stored="true" required="true" />
   <field name="authorids"  type="string"    indexed="true"  stored="true" required="false" multiValued="true" />
   <field name="tagids"     type="string"    indexed="true"  stored="true" required="false" multiValued="true" />
   <field name="countryids" type="string"    indexed="true"  stored="true" required="false" multiValued="true" />
   <field name="modified"   type="date" indexed="true"  stored="true" required="true" />
   <field name="published"  type="date" indexed="true"  stored="true" required="true" />
   <field name="added"      type="date" indexed="true"  stored="true" required="true" />
   <field name="title"      type="text" indexed="true"  stored="true" required="true" />
   <field name="excerpt"    type="text" indexed="true"  stored="true" required="true" />
   <field name="body"       type="text" indexed="true"  stored="true" required="true" />
   <field name="layoutid"   type="string" indexed="false" stored="true" required="true" />
   <field name="shortcut"   type="string" indexed="false" stored="true" required="true" />
   <field name="statusid"   type="string" indexed="false" stored="true" required="true" />
   <field name="contentid"  type="string" indexed="false" stored="true" required="true" />
   <field name="uid"        type="string" indexed="true"  stored="true" required="true" />
 </fields>

1 个答案:

答案 0 :(得分:0)

雅阿。这是因为statusid字段。对于indexed="false"字段,您无法对其进行查询。只需删除状态是查询的一部分,您的查询应该有效。

q=(title:"Merkel" OR body:"Merkel" OR excerpt:"Merkel") AND sitecode:GIR