question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[ElasticSearch] SearchTerm is ignored when adding a predefined filter to the search-ui config

See original GitHub issue

Describe the bug SearchTerm is ignored when adding a predefined filter to the search-UI config. So doesn’t matter what you search on, the search will just return the items from the predefined filters.

To Reproduce

  1. add filter to the searchQuery object for example"
searchQuery: {
    filters: [{ field: "id", type: "all", values: ["park_acadia"]}],

https://codesandbox.io/s/github/elastic/search-ui/tree/master/examples/sandbox?file=/src/pages/elasticsearch/index.js:1108-1121

Note that for App Search this works fine!

  1. search for a value that you know will not give any results like ///\\/\/\/\/\/\/\//\\\

You will see that you will still get the result of the filter…

Expected behavior

  • searchTerm must still work when having predefined filters

Which backends and packages are you using: Backend: [Elastic Search cloud]

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

Issue Analytics

  • State:open
  • Created a year ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
RobbyUitbeijersecommented, Nov 2, 2022

hi there! Not sure if related, but we came to an interesting situation and it feels like the right issue to post this in.

The filter we are applying looks like this:

      filters: [
        {
          field: 'owner.keyword',
          values: [userAddress],
          type: 'all' as const,
        },
      ],

Within the input that you can see in the video below, we would would like to allow users to further specify the results they are seeing by allowing them to set a search term on top of the pre-defined filters in the config. Just to clarify, this is the handler for setting the search term:

        onChange={e => setSearchTerm(e.target.value)}

Combining this, we do actually see that setSearchTerm seems to be working, but it seems to sort the results rather than filtering out results that can be considered irrelevant by setting the searchTerm. Please note that the items you see in the video is the subset of our total index based on the pre-defined filters.

https://user-images.githubusercontent.com/10176709/199464191-987406c7-f335-4ab0-9e50-cbec45e77ac1.mp4

I’ve tried to debug the query that gets sent over to Elastic by logging the request body. The interesting part is that setting the search term (and filters) client side through the input onChange leads to quite a bit of a different query compared to the an initial query where filters + a search term is applied

1reaction
JasonStoltzcommented, Oct 31, 2022

@ZakKa89 If you want to help us fix any of this… we are hiring 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

Term query | Elasticsearch Guide [8.5] | Elastic
The term query does not analyze the search term. The term query only searches for the exact term you provide. This means the...
Read more >
elastic-search-ui/community - Gitter
I have two more questions, hoping they're not too much: is it possible to change the SearchDriver's state (especially filters) without triggering a...
Read more >
Elastic search filtered query, query part being ignored?
Your filter is not at the right level. It should not be inside query but at the same level as query like this:...
Read more >
@elastic/react-search-ui - npm
Headless Core - Leverage our application logic and provide your own Components or view. URL query string synchronization - Searches, filtering, ...
Read more >
Search Experience - Open Distro for Elasticsearch
Highlight query matches, Highlight the search term in the results. ... To configure a field to use edge N-grams, create an autocomplete analyzer...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found