# Completion suggester across multiple indices

**URL:** https://discuss.elastic.co/t/completion-suggester-across-multiple-indices/122403
**Category:** Elasticsearch
**Created:** [March 4, 2018, 10:48am UTC](https://discuss.elastic.co/t/completion-suggester-across-multiple-indices/122403 "2018-03-04T10:48:51Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![neshta](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/neshta/32/27727_2.png) [@neshta](https://discuss.elastic.co/u/neshta)
#### Post date: [March 4, 2018, 10:48am UTC](https://discuss.elastic.co/t/completion-suggester-across-multiple-indices/122403/1 "2018-03-04T10:48:51Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![neshta](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/neshta/32/27727_2.png) [@neshta](https://discuss.elastic.co/u/neshta)
#### Post date: [March 5, 2018, 5:57pm UTC](https://discuss.elastic.co/t/completion-suggester-across-multiple-indices/122403/2 "2018-03-05T17:57:24Z")

</div>

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](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.

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)
#### Post date: [April 2, 2018, 5:57pm UTC](https://discuss.elastic.co/t/completion-suggester-across-multiple-indices/122403/3 "2018-04-02T17:57:32Z")

</div>

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