We can also pass filter query as a configuration parameter to the Solarium query using the addFilterQuery()
function. For this, we need to first define the filter query as a configuration array and then add it to the Solarium query.
$fqconfig = array( "query"=>"inStock:true", "key"=>"Availability", ); $query = $client->createSelect(); $query->addFilterQuery($fqconfig);
The Solr query created by the preceding configuration is similar to the one created earlier. The benefit of using filter query configuration is that we can define multiple standard filter queries as configurations and add them in our Solr query as required. The addTag(String $tag)
and addTags(array $tags)
functions are used to define tags in the filter queries. We can use these tags to exclude certain filter queries in facets. We will go through an example later.