App Search with minimum_should_match query

Hi all, I am new to Elastic App Search. I am using @elastic/app-search-javascript 7.6.0 to do the search. When I tried to search "Food 1" (without quote, I don't want do have an exact search), I got all the documents with "1" as well. How to deal with this?

I tried to use minimum_should_match from query_string like this as from Elasticsearch document

const query = {query: {
        query_string: {
          query: str,
          fields: ["title", "tags", "keywords"],
          minimum_should_match: "75%"
        }
      }
}

...
client.search(query, options)
....
However, app search document api throw the error Error: [400] Query must be a string or number.

Thank you in advance for the help.

It looks like you are mixing Elasticsearch query syntax with App Search syntax. Make sure you are querying with the App Search search syntax described here: Search API | Swiftype Documentation.

When I tried to search "Food 1" (without quote, I don't want do have an exact search), I got all the documents with "1" as well. How to deal with this?

This sounds like the expected behavior to me. What were you expecting?

Thanks @JasonStoltz for the getting back to me. I just want to get rid of some unexpected results. When I search for Food 1, all the unexpected documents with just "1" (could be the same with stopwords such as "a", "the"?) are included. It would be great if you can suggest for a solution.
Also any option to search with AND operator rather than OR by app search?

Thanks,

You can use Lucene Query Syntax to perform an AND: https://swiftype.com/documentation/app-search/api/search#lucene

I don't think you can define "1" as a stopword, to do something like that I'd try indexing an alternate version of your fields that have numbers stripped out, which you could use for searching.

Thanks @JasonStoltz, At first I thought App search api is would be wrapper for Elastic search rest api, but looks like its not. The option to search is very limit.

Thank you for your time. Appreciate it.

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