Skip to content

Commit

Permalink
Fix creating non-unique filters in the visualization (elastic#66595)
Browse files Browse the repository at this point in the history
  • Loading branch information
dokmic committed May 12, 2021
1 parent 86ab342 commit 95f4780
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -105,4 +105,11 @@ describe('createFiltersFromValueClick', () => {
expect(rangeFilter.range.bytes.lt).toEqual(2078);
}
});

test('handles non-unique filters', async () => {
const [point] = dataPoints;
const filters = await createFiltersFromValueClickAction({ data: [point, point] });

expect(filters.length).toEqual(1);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
* Side Public License, v 1.
*/

import _ from 'lodash';
import { Datatable } from '../../../../../plugins/expressions/public';
import { esFilters, Filter } from '../../../public';
import { getIndexPatterns, getSearchService } from '../../../public/services';
Expand Down Expand Up @@ -140,5 +141,7 @@ export const createFiltersFromValueClickAction = async ({
})
);

return esFilters.mapAndFlattenFilters(filters);
return _.uniqWith(esFilters.mapAndFlattenFilters(filters), (a, b) =>
esFilters.compareFilters(a, b, esFilters.COMPARE_ALL_OPTIONS)
);
};

0 comments on commit 95f4780

Please sign in to comment.