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

[ElasticSearch] Can't filter onAutocomplete results

Open ZakKa89 opened this issue 3 years ago • 3 comments

Describe the bug

Can't filter onAutocomplete results, there is no mention in the docs, but the type definition allows me to add the filters. https://docs.elastic.co/search-ui/api/core/configuration#autocomplete-query

Question: The docs also mention a global queryConfig which could maybe solve/workaround my problem: https://github.com/elastic/search-ui/issues/890

To Reproduce Steps to reproduce the behavior:

Put this in results on autocompleteQuery for the search UI config

  autocompleteQuery: {
    results: {
      filters: [{ field: "id", type: "all", values: ["park_wind-cave"] }],

https://codesandbox.io/s/nice-curie-fy9js1?file=/src/pages/elasticsearch/index.js

Note that in App Search this works fine! I tested both in the sandbox!

Expected behavior Only show autosuggestion with that id if not supported yet, don't add it to the type definition and make it clear in the docs.

Screenshots image image

Which backends and packages are you using: Backend: [Elasticsearch] Packages: [react-search-ui]


     // frontend
    "@elastic/react-search-ui": "^1.17.1",
    "@elastic/react-search-ui-views": "^1.17.1",
    "@elastic/search-ui": "^1.17.1",
     // api
    "@elastic/elasticsearch": "^8.2.1",
    "@elastic/search-ui-elasticsearch-connector": "^1.17.1",


ZakKa89 avatar Oct 28 '22 10:10 ZakKa89

I looked into the package itself: It does look like there is no code related to filters at all in the autocomplete folder:

handlers/autocomplete/index.js

while in handlers/search there is something done with the filters object:

        const baseFilters = buildBaseFilters(queryConfig.filters);

ZakKa89 avatar Oct 28 '22 10:10 ZakKa89

Great catch, again. I appreciate the bug report.

JasonStoltz avatar Oct 31 '22 16:10 JasonStoltz

Hey @JasonStoltz, any timelines for getting this implemented?

In another thread, you mentioned that the filtering feature is not planned for App Search suggestions. Do you know if this also holds in the context of this bug report? If yes, is a workaround possible (within the context of using @elastic/react-search-ui)?

Cheers! ./.rc

plavaga-rc avatar Jul 26 '24 06:07 plavaga-rc