Getting a specific term / phrase suggestion

I am looking to get a specific set of results from a suggester. I am indexing a bunch of documents that have keywords like the following:

"shop in berlin"
"restaurant in frankfurt"

When the user enters a search term like

"shop berlin"

I would like to get

"shop in berlin"

as a suggestion.

My current mapping is as follows:

    "filter": {
  "shingle_filter": {
    "max_shingle_size": "3",
    "min_shingle_size": "2",
    "type": "shingle"
    }
  },
  
  "analyzer": {
    "did_you_mean_analyzer": {
    "filter": [
      "lowercase", "shingle_filter"
    ],

    "type": "custom",
    "tokenizer": "keyword"
  },

When sending the query with

  "suggest": {
"simple_phrase": {
  "text": "shop berlin",
  "phrase": {
      "field": "suggest.did_you_mean",
      "max_errors": 3
    }
  }
},

no suggestions are being returned. However, if I add an extra whitespace between "shop" and "berlin" in the query it returns the correct suggestion: shop in berlin:

  "suggest": {
"simple_phrase": {
  "text": "shop  berlin",
  "phrase": {
      "field": "suggest.did_you_mean",
      "max_errors": 3
    }
  }
},

Increasing the max_errors parameter does not help. Is this even the right approach for this case? Essentially I am looking to get existing multi-word keywords as suggestion which have an similarity to the users input.

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