FilterManagerBundle
FilterManagerBundle copied to clipboard
Range filter doesnt use related search
In preProcessSearch
method of Range filter stats aggregation is added:
https://github.com/ongr-io/FilterManagerBundle/blob/103bd481e20b265fb39fa545070da23614f30110/Filter/Widget/Range/Range.php#L63
it provides data for max and min values, but, it aggregates on all documents instead of limiting to current search. IMO it should add a FilterAggregation
with post filters from related search instance like it is done in filters like choice, dynamic aggregate and others. Any thoughts?
It should, this is a bug.
This bug still existing, any fix?
Yes it is still here, filter manager could be revised after ElasticsearchBundle will be done.
The faster way would be if somebody could create a fix by PR and then I would merge and release a patch ;)
I'm investigating about it. If I found any solution will create a PR.
I'm testing it. According with @einorler i'm trying to add the FilterAggregattions of search instance but atm without results.
/**
* {@inheritdoc}
*/
public function preProcessSearch(Search $search, Search $relatedSearch, FilterState $state = null)
{
$stateAgg = new StatsAggregation($state->getName());
$stateAgg->setField($this->getDocumentField());
/** @var FilterAggregation $filter */
foreach ($search->getAggregations() as $filter)
{
$stateAgg->addAggregation($filter);
}
$search->addAggregation($stateAgg);
}
Any suggest whould be appreciated :)