简体   繁体   English

SOLR或查询PHP

[英]SOLR OR query PHP

The code I currently have looks like this: 我目前拥有的代码如下所示:

$query -> addFilterQuery(array(
    'key'=>feature,
    'query'=>'Features:1,7 Ghz',
    'tag'=>'include'
))

What I need is both the results for 1,7 Ghz and 2,0 Ghz. 我需要的是1,7 Ghz和2,0 Ghz的结果。 Adding another filter query uses an AND operator, but what I need is an OR operator. 添加另一个过滤器查询使用AND运算符,但我需要的是OR运算符。

I've read that the setQuery() function does use an OR operator, but I cannot figure out how to work that out with multiple values. 我已经读过setQuery()函数确实使用OR运算符,但是我无法弄清楚如何使用多个值来解决这个问题。

I've been looking for this for a while, but I can't find any documentation on this. 我已经寻找了一段时间,但是我找不到任何文档。

If anything is unclear please let me know (not my native language) 如果不清楚,请告诉我(不是我的母语)

Using plain Lucene syntax should work fine, depending on the escaping performed by the Solr library you're using: 根据您所使用的Solr库执行的转义,使用普通的Lucene语法应该可以正常工作:

'query' => 'Features:("1,7 Ghz" OR "2,0 Ghz")'

This can also be combined as multiple separate statements referring to a field: 也可以将其组合为引用字段的多个独立语句:

'query' => 'Features:"1,7 Ghz" OR Features:"2,0 Ghz"'

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM