I'm working with Solr + Solarium. I have defined a multi facet search. Each facet options has counters behind them showing the number of returned results when you click on it.
When selecting an option within a multi-select facet I would expect that the counters of the others facets still work.
There are results in solr. In my old code (single select facets) it returned values for petrol/diesel.
E.g. the following 2 facets:
Car brands: -volvo (3) -mazda (2) -volkswagen (5)
Fuel: -Diesel (4) -Petrol (6)
Now i would like to be able to select Volvo AND Mazda. After selecting Volvo solr/solarium is returning the following 2 facets:
Brand: -volvo (3) - selected -mazda (2) -volkswagen (5)
Fuel: -Diesel (0) -Petrol (0)
The brand facet is good. I would expect the Fuel facet counter to return the number of Diesel/Petrol cars from volvo. E.g: -Diesel (2) -Petrol (1)
My code:
$exclude= array("brand");
$q_brand = id_brand:volvo
$q_fuel = "";
// create a client instance
$client = new Solarium_Client($config);
// get a select query instance
$query = $client->createSelect();
$query->createFilterQuery(array('key'=>'id_brand', 'query'=>'$q_brand', 'tag'=>'brand'));
$query->createFilterQuery(array('key'=>'id_fuel', 'query'=>'$q_fuel', 'tag'=>'fuel'));
// get the facetset component
$facetSet = $query->getFacetSet();
$facetSet->createFacetField('id_brand')->setField('id_brand')->setExcludes($exclude);
$facetSet->createFacetField('id_fuel')->setField('id_fuel');
// this executes the query and returns the result
$resultset = $client->select($query);
// display facet counts
echo '<hr/>Facet counts for field "id_brand":<br/>';
$facet = $resultset->getFacetSet()->getFacet('id_brand');
foreach ($facet as $value => $count) {
echo $value . ' [' . $count . ']<br/>';
}
// display facet counts
echo '<hr/>Facet counts for field "id_fuel":<br/>';
$facet = $resultset->getFacetSet()->getFacet('id_fuel');
foreach ($facet as $value => $count) {
echo $value . ' [' . $count . ']<br/>';
}