First 2 characters have no typo tolerance in App Search

Like the title said, we have an issue, on multiple environments and in multiple engines.
Where when we mistype the first or second character App Search does not return any relevant results.

Example we have a document with the title "simple" I mistype it in my query with "sample" this will return NO results, same with other use cases.
we have a document with the title "smile" I mistype it in my query with "stile" it returns no results despite only one character being different.

If I do this with other letters than the first 2 I do get relevant results.

No matter how low I set my precision tuning It does not work.

We have thought this might be because the prefix_length is set to 2 even on the lowest precision tuning.

We would like to be able to continue using App Search's search however also have typo tolerance for the first two characters.

Any help would be appreciated.

Kind regards,
Chenko Mortier

Hi @Chenko thanks for the feedback. In this case, App Search is working as designed.

Here's an example snippet of what this generated query is, of course your fields will be different:

                                "multi_match": {
                                  "query": "park",
                                  "minimum_should_match": "1<-1 3<49%",
                                  "type": "best_fields",
                                  "fuzziness": "AUTO",
                                  "prefix_length": 2,
                                  "fields": [

The important point to note is that in the multi_match query that App Search generates, the prefix_length is set to 2. This is described in the parameters for the fuzzy query.

Here's a simple example that illustrates this:

PUT discuss-test/_doc/1
  "title": "A tale of two cities",
  "text": "It was the best of times, it was the worst of times"

POST discuss-test/_search
  "query": {
    "multi_match": {
      "query": "cties",
      "fields": [ "title", "text" ], 
      "fuzziness": "AUTO", 
      "prefix_length": 2

If you set the prefix_length to a smaller number then cties will return the document.

App Search is a very opinionated piece of software, and part of what makes it so easy to use out of the box is that opinionatedness. Unfortunately that comes with somewhat less flexibility than using the Elasticsearch search platform directly.

If there are specific queries that you are concerned with you may be able to put in synonyms or curations as a workaround. And of course you always have the option of modifying this query and sending it via the Elasticsearch Search API. But otherwise, it is a technical limitation of App Search.

1 Like

FYI - this has now been clarified in our documentation

1 Like