我有一个查询:
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
如果我尝试将"或"替换为"one_answers"或添加括号,也会发生同样的情况。
但如果这样做:
http://localhost:8983/solr/example/select?&q=title:"King Kong" title:"Snow Queen"&wt=json
它有效,结果正确。
换句话说,http请求传递或'ed/and'ed查询的正确语法是什么。
我偶然学会了解决方案:
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
小写字母确实有意义。;-)