如何在 solr 中搜索 or'ed 属性
How to search in solr for or'ed attributes
我有一个查询:
http://localhost:8983/solr/example/select?q=title:"King Kong"&wt=json
返回一份文档的结果。
我有两个查询:
http://localhost:8983/solr/example/select?q=title:"Snow Queen"&wt=json
返回一份文档的结果。
我正在尝试学习本教程:
http://www.solrtutorial.com/solr-query-syntax.html
据我了解,建议我应该这样做:
http://localhost:8983/solr/example/select?q=title:"King Kong" or title:"Snow Queen"&wt=json
然而它产生了 0 个结果。实际上它与此有效载荷有关:
metadata: [
"error-class",
"org.apache.solr.common.SolrException",
"root-error-class",
"org.apache.solr.common.SolrException"
],
msg: "undefined field text",
code: 400
如果我尝试用 'and' 替换 'or' 或添加括号,也会发生同样的事情。
但如果这样做:
http://localhost:8983/solr/example/select?&q=title:"King Kong" title:"Snow Queen"&wt=json
有效,结果正确或运算。
换句话说,HTTP 请求中传递或“ed/and”查询的正确语法是什么。
一不小心学到了解决方法:
http://localhost:8983/solr/example/select?q=title:"King Kong" OR title:"Snow Queen"&wt=json
或更复杂的情况:
http://localhost:8983/solr/example/select?q=title:"King Kong" OR (title:"Snow Queen" AND type:"Fairy tale")&wt=json
总之大写字母是有意义的。 ;-)
我有一个查询:
http://localhost:8983/solr/example/select?q=title:"King Kong"&wt=json
返回一份文档的结果。
我有两个查询:
http://localhost:8983/solr/example/select?q=title:"Snow Queen"&wt=json
返回一份文档的结果。
我正在尝试学习本教程:
http://www.solrtutorial.com/solr-query-syntax.html
据我了解,建议我应该这样做:
http://localhost:8983/solr/example/select?q=title:"King Kong" or title:"Snow Queen"&wt=json
然而它产生了 0 个结果。实际上它与此有效载荷有关:
metadata: [
"error-class",
"org.apache.solr.common.SolrException",
"root-error-class",
"org.apache.solr.common.SolrException"
],
msg: "undefined field text",
code: 400
如果我尝试用 'and' 替换 'or' 或添加括号,也会发生同样的事情。
但如果这样做:
http://localhost:8983/solr/example/select?&q=title:"King Kong" title:"Snow Queen"&wt=json
有效,结果正确或运算。
换句话说,HTTP 请求中传递或“ed/and”查询的正确语法是什么。
一不小心学到了解决方法:
http://localhost:8983/solr/example/select?q=title:"King Kong" OR title:"Snow Queen"&wt=json
或更复杂的情况:
http://localhost:8983/solr/example/select?q=title:"King Kong" OR (title:"Snow Queen" AND type:"Fairy tale")&wt=json
总之大写字母是有意义的。 ;-)