简体   繁体   中英

How write solr query in PHP SOLR CLIENT

I use apache solr 3.6, and php solr client. Now i do simple solr queries like $query = 'url:"'.$searchSubject.'"'; where $searchSubject is one word. 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.

Now i can add only 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

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

if you would like to search for two urls, the query can be

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

In solr you can simply create query for multiple words.

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

space between $searchSubject1 and $searchSubject2 will take default OR condition.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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