Reputation: 175
I am trying to use facet in solr, i want to make a search on my database and i need to get articles that belong to specific date and specific publisher.
i used this url on the browser: localhost:8888/solr//collection1/select/?q=:&version=2.2&start=0&rows=10&indent=on&facet=true&fq=publisher_name:"Saudi Press Agency (SPA)"&fq=datecreated:20110725
and it works fine. I am using (search()) function in apache_solr_service class in my php code. and i set the array as below:
array('facet'=>'true','fq'=>"datecreated:".$date,'fq'=>"publisher_name:\"".$publisher.'"')
I know it wont give me the expected results because of fq index, it will overwrite the value of fq into publisher_name
but how can i set this query with two facet queries
Upvotes: 1
Views: 2849
Reputation: 11
You could also write it like this:
array('fq'=>'+datecreated:'.$date.' +publisher_name:"'.$publisher.'"')
http://wiki.apache.org/solr/CommonQueryParameters#fq
Upvotes: 1
Reputation: 3450
This might help: http://code.google.com/p/solr-php-client/wiki/FAQ#How_Can_I_Use_Additional_Parameters_%28like_fq,_facet,_etc%29
This is what the code should look like (please check for syntax errors, my PHP is rusty):
array('facet'=>'true','fq'=>array('datecreated:'.$date,'publisher_name:"'.$publisher.'"')
Upvotes: 1
Reputation: 13394
use AND operator:
array('fq'=> 'datecreated:'.$date.' AND publisher_name:"'.$publisher.'"');
Upvotes: 0