Change AppSearch Query

Hello

I am using Appsearch to power search for an application, I know that App search take care of the mapping & analyzer, and also the search query, when doing some inspection, i could see the kind of the search query sent to ES endpoint, something like this

 {
                    "multi_match": {
                      "query": "United Kingdom",
                      "minimum_should_match": "1<-1 3<49%",
                      "boost": 1,
                      "type": "cross_fields",
                      "operator": "OR",
                      "fields": [
                        "country$string^1.0",
                        "country$string.stem^0.95",
                        "country$string.prefix^0.1",
                        "country$string.joined^0.75",
                        "country$string.delimiter^0.4",
                        "name$string^1.0",
                        "name$string.stem^0.95",
                        "name$string.prefix^0.1",
                        "name$string.joined^0.75",
                        "name$string.delimiter^0.4",
                        "external_id^1.0"
                      ]
                    }
                  }

My search logic does not require searching on fields analyzed diffrently like stem, prefix, joinded, i want to search only on the basic fields like : country$string & name$string

How i can change the behavior of App search to search only on fields i want to avoid getting some noises :slight_smile:

Like if i want to ask App search to send something like this

 {
                    "multi_match": {
                      "query": "United Kingdom",
                      "minimum_should_match": "1<-1 3<49%",
                      "boost": 1,
                      "type": "cross_fields",
                      "operator": "OR",
                      "fields": [
                        "country$string^1.0",
                        "name$string^1.0"
                      ]
                    }
                  }

Thank You

I found a related topic to my issue here

This typically my use case, where the ngram analyzer is bringing some inexpected facets :slight_smile:

Hi Yassine,

I don't think there's a way to do what you described currently.

If you want to increase precision, I recommend upgrading to v7.12 if you're not already on it. Here are a couple of items from the changelog:

Enterprise Search 7.12

Improves query precision:

  • Increased query precision with fewer long-tail results.
  • Improved typo-tolerance for more resilient search.

If you decide to upgrade, make sure to follow the upgrade instructions, this release is special.

Also, we have a feature in our near-term roadmap that will allow you to improve precision even further. I cannot commit to specific timelines, though.

Hope it helps!
Vadim

1 Like

Thanks @Vadim_Yakhin for your feedback
Appreciate

1 Like

One workaround is to add any Boolean operators (AND/OR/NOT or ") to your query string.
This changes the search logic from being interpreted as a fuzzy match to exact-string matching.

1 Like

Many thanks @Mark_Harwood
That's definetly a nice workaround

1 Like