FilterManagerBundle icon indicating copy to clipboard operation
FilterManagerBundle copied to clipboard

Range filter doesnt use related search

Open einorler opened this issue 8 years ago • 5 comments

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?

einorler avatar Nov 16 '16 14:11 einorler

It should, this is a bug.

saimaz avatar Nov 17 '16 07:11 saimaz

This bug still existing, any fix?

borjadinamic avatar Jun 26 '18 09:06 borjadinamic

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 ;)

saimaz avatar Jun 26 '18 10:06 saimaz

I'm investigating about it. If I found any solution will create a PR.

bnd170 avatar Jun 26 '18 11:06 bnd170

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 :)

bnd170 avatar Jun 26 '18 13:06 bnd170