search-ui icon indicating copy to clipboard operation
search-ui copied to clipboard

Queries are hitting 32 filter limit prematurely.

Open SaraMoad opened this issue 2 years ago • 2 comments

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: image We can see the request here: image

Which backends and packages are you using: Backend: [App Search] Packages: [react-search-ui, search-ui-app-search-connector]

SaraMoad avatar Aug 04 '22 14:08 SaraMoad

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

joemcelroy avatar Aug 04 '22 16:08 joemcelroy

I’m also stuck with this issue!!

JamesLove002 avatar Aug 06 '22 00:08 JamesLove002

HI @joemcelroy, is there any update on the fix for this issue?

wentaoxu415 avatar Sep 02 '22 20:09 wentaoxu415

no update yet @wentaoxu415. I will try get this prioritized.

joemcelroy avatar Sep 08 '22 07:09 joemcelroy

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.

joemcelroy avatar Sep 29 '22 13:09 joemcelroy

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.

JasonStoltz avatar Sep 29 '22 16:09 JasonStoltz

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.

joemcelroy avatar Oct 10 '22 12:10 joemcelroy