Search code examples
solrsolarium

Faceted search in solr using solarium with multiple values of the same field


I am indexing my data in solr along with the id related to the community associated with it .

For eg these are the blogs i get when i search for a specific query but i want to further filter them based on community Id's:-

Blog1- Community id :1
Blog2- Community id :2
Blog3- Community id :1
Blog4- Community id :3

I want to get blogs for the community id 1 and 2

I have tried a lot of iteration along this pattern

$query->createFilterQuery('community')->setQuery('community:'.$community[1].' OR'.'community:'.$community[0]);

Here community[1]=1 and community[0]=2

Does any one know the specific format to do this thing. I am using solarium to interact with solr.

Range doesn't work for me as i could be looking for ID's 1 and 3 also together


Solution

  • If I would i have to write the query to find those records having id 1 OR 3, then my query will be

    q=:&fq=community_id:(1 3)&fl=blogs,community_id

    & by default filter is OR, so I didn't mentioned it in my query.

    I am not aware of solarium but you could try like:

    $query->createFilterQuery('community')->setQuery('community:('.$community[1].' '.$community[0].')');

    I hope this works, again I am not aware of solarium but from above solr query you can take a guess.