Completion suggester across multiple indices

ElasticSearch 6.x does not support multiple type mappings in a single index. So I have for example 2 indices:

  • location
  • postcode

I want to have autocomplete functionality (I use completion suggester) using both indices. Is it possible?

This is my example of mapping location index:

{
  "location": {
    "mappings": {
      "location": {
        "properties": {
          "id": {
            "type": "long"
          },
          "name": {
            "type": "text"
          },          
          "suggest": {
            "type": "completion",
            "analyzer": "simple",
            "preserve_separators": false,
            "preserve_position_increments": false,
            "max_input_length": 50
          }
        }
      }
    }
  }
}

And postcode index:

{
  "postcode": {
    "mappings": {
      "postcode": {
        "properties": {
          "code": {
            "type": "text"
          },
          "suggest": {
            "type": "completion",
            "analyzer": "simple",
            "preserve_separators": true,
            "preserve_position_increments": true,
            "max_input_length": 50
          }
        }
      }
    }
  }
}

It's possible to do a request if I just skip index name in a request, e.g.

POST _search
{
  "suggest": {
    "suggestion": {
      "prefix": "abc",
      "completion": {
        "field": "suggest"
      }
    }
  }
}

It searches in both indices but the result is incorrect. For example in the previous request we're searching for values start with abc. If location index contains many documents with values start with abc, e.g. abcd or abcde, then the response won't contain values from postcode index even if it contains exact value abc.

As I understand the problem is that Completion Suggester works only per index. FST is built per index. So in my case a have 2 graphs. I'm looking for apportunity to combine these graphs.

I wasn't right about incorrect behavior across multiple indices. If we use only one index (e.g. location) and PUT one more document with suggest value abc, then we will see the same behavior. It happens because all results have the same score = 1.

So how can I have a bigger score for exact matches?

I found this closed ticket (https://github.com/elastic/elasticsearch/issues/4759) but I don't understand what should I do to achive appropriate behaviour? It does not work out of the box.

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