简体   繁体   English

如何在 PHP SOLR CLIENT 中编写 solr 查询

[英]How write solr query in PHP SOLR CLIENT

I use apache solr 3.6, and php solr client.我使用 apache solr 3.6 和 php solr 客户端。 Now i do simple solr queries like $query = 'url:"'.$searchSubject.'"';现在我做简单的 solr 查询,比如$query = 'url:"'.$searchSubject.'"'; where $searchSubject is one word.其中$searchSubject是一个词。 But I want to make some queries with two or more words.但我想用两个或更多词进行一些查询。 I don't understand how i must add some other parameters into code of PHP SOLR CLIENT.我不明白我必须如何将一些其他参数添加到 PHP SOLR CLIENT 的代码中。

Now i can add only query, offset , limit .现在我只能添加 query, offset , limit 。 $response = $this->solr->search($query, $offset = 0, $limit = 10000);

You can just insert multiple words into the parameter $query using the format specified in lucene query parser syntax您可以使用lucene 查询解析器语法中指定的格式在参数 $query 中插入多个单词

$query = 'url:"' . $searchSubject . '"'; $query = 'url:"' . $searchSubject . '"';

if you would like to search for two urls, the query can be如果你想搜索两个网址,查询可以是

$query = 'url:("' . $searchSubject1 . '" OR "' . $searchSubject2 . '")'; $query = 'url:("' . $searchSubject1 . '" OR "' . $searchSubject2 . '")';

In solr you can simply create query for multiple words.在 solr 中,您可以简单地为多个单词创建查询。

$query = url:"($searchSubject1 $searchSubject2 $searchSubject3)";

space between $searchSubject1 and $searchSubject2 will take default OR condition. $searchSubject1 和 $searchSubject2 之间的空格将采用默认 OR 条件。

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

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