Complex filters in app searchui

I have a complex quiery that I have working find in the search API via post to elastic app search. Basically its a nested all and any query like so

I have a very complex nested query filter that i can get working in the api call like so (small example, its gets more complex)


{ "all": [
          {
              "pattern": "6x6"
          },
          {
              "core": {
                  "from": 78.1,
                  "to": 900
              }
          }
      ] ,
      "any": [
          {
              "all": [
                  {
                      "size": [
                          "20x10",
                          "10x4"
                      ]
                  },
                  {
                      "space": {
                          "from": 10,
                          "to": 35
                      }
                  }
              ]
          }
        ],
       .......etc
}

I want to set this filter in a page so that only these show in the APP search UI
In the app search config you can set a filter like so, but I am not sure how to add the all/any for this to work

filters : [{field: 'pattern', values: ["6x6"]},
      {field:'core', values: [{name: "core", from: 78.1, to: 900}]},
     ?????
],

Any ideas how to get this full filter working?

Have you tried copying your example query that you shared into the filters attribute within the app search config that you mentioned? If so, could you take a look at the network request within the browser? I think this could be a bug and its been highlighted on a somewhat seperate issue Queries are hitting 32 filter limit prematurely. · Issue #837 · elastic/search-ui · GitHub

Create a bug report within the search-ui repo with the XHR request thats performed and we can take a look!

Joe

Yes but It does not get to the network as when i do that is crashes the app. It appears the format is wrong. The data structure that works is an array of objects and the one I paste in is an object structure.

app.js:94 Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'load')
    at app.js:94:42
    at Array.forEach (<anonymous>)
    at app.js:93:29
(anonymous) @ app.js:94
(anonymous) @ app.js:93
Promise.then (async)
(anonymous) @ app.js:92
e @ jquery.min.js:2
t @ jquery.min.js:2
setTimeout (async)
(anonymous) @ jquery.min.js:2
c @ jquery.min.js:2
fireWith @ jquery.min.js:2
fire @ jquery.min.js:2
c @ jquery.min.js:2
fireWith @ jquery.min.js:2
ready @ jquery.min.js:2
B @ jquery.min.js:2
helpers.js:99 Uncaught TypeError: filters2.reduce is not a function
    at mergeFilters (helpers.js:99:1)
    at SearchDriver.js:178:126
    at later (DebounceManager.js:12:1)

I just tried it with national parks and it gives an error

const config = {
  searchQuery: {
    facets: buildFacetConfigFromConfig(),
    ...buildSearchOptionsFromConfig(),
    filters: [{
      "any": [
        {
          "all": [
            { "states": "California" },
            { "world_heritage_site": "true" }
          ]
        }
      ]
    }]
  },

An unexpected error occurred: Cannot read properties of undefined (reading 'map')

This works

const config = {
  searchQuery: {
    facets: buildFacetConfigFromConfig(),
    ...buildSearchOptionsFromConfig(),
    filters : [{field: 'world_heritage_site', values: ["true"]}],
  },
  autocompleteQuery: buildAutocompleteQueryConfig(),
  apiConnector: connector,
  alwaysSearchOnInitialLoad: true
};

But i have no idea how to nest it

Im pretty positive that although the API supports nested, Search UI doesn't. Could you open a ticket in Search UI repo and we will take a look :slight_smile:

Joe

Thanks I opened up #850.

Any suggestions on how to work around this? I have a use case for finding all parts that fit which requires a nested query that works fine in the api but no luck in the ui.

Thanks @Daniel_Kozlowski

Sorry, I don't have any good workarounds atm for this issue. I can understand it is a blocker. We will try and investigate this next week and hopefully have a resolution for you by then.

Joe

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.