search-ui
search-ui copied to clipboard
Queries are hitting 32 filter limit prematurely.
Describe the bug
- I am trying to use an array to filter which records should be returned.
- I am passing an array of ~500 values in. I am getting the error 'An unexpected error occurred: [400] Filters cannot have more than 32 filters'
- I am have done so trying to follow the guidance laid out here:
To Reproduce
const config: SearchDriverOptions = { searchQuery: { facets: buildFacetConfigFromConfig(), disjunctiveFacets: ["level", "castingtime", "rarity", "ispfslegal", "traits", "subtype", "school", "area", "duration", "range", "savingthrow", "targets"], ...buildSearchOptionsFromConfig(), filters: [ { field: "nethysid", type: "any", values: spellsToShowIDs } ] }, autocompleteQuery: buildAutocompleteQueryConfig(), apiConnector: connector, alwaysSearchOnInitialLoad: true };
Expected behavior I expect the array spellsToShowIDs to filter successfully.
Screenshots
We can see the array size that i'm using, and the log of the config object here:
We can see the request here:
Which backends and packages are you using: Backend: [App Search] Packages: [react-search-ui, search-ui-app-search-connector]
thanks for the report! Will try get back to you, i suspect this is an issue with how we unroll filters together. Linked with https://github.com/elastic/search-ui/issues/763
I’m also stuck with this issue!!
HI @joemcelroy, is there any update on the fix for this issue?
no update yet @wentaoxu415. I will try get this prioritized.
I've started looking into this bug. Few things want to highlight:
- We are currently creating a new "filter" per value, even if it was grouped together inside values. This hits a ceiling fast with only 32 filters can be applied.
- we should be using one filter per field with an array of values. https://www.elastic.co/guide/en/app-search/current/filters.html#filters-arrays-all-none
- ranges will not be able to be grouped together. Requires a filter per range type
I've opened a PR which should solve the problem. Hopefully next week we can publish a release.
we should be using one filter per field with an array of values. https://www.elastic.co/guide/en/app-search/current/filters.html#filters-arrays-all-none
We can use the array syntax as long as folks are applying filters as "any" (OR). We can't use the same array method to group values if they are meant to be "all" (AND).
The 32 filter limit is hardcoded in App Search. Many of these limits can be overridden, but unfortunately not the filter limit.
I think for the most part though, most folks applying a large number of filters like we see above will be applying them as an "any" filter, not "all", so our PR should help.
now been released under v1.18.1 🎉 This change will rollup the filters into a single multi value OR or NOT type filter. an AND type filter still will need a filter per value.