# Use phrase suggester over multiple indices

**URL:** <https://discuss.elastic.co/t/use-phrase-suggester-over-multiple-indices/166956>\
**Category:** Elasticsearch\
**Created:** [February 4, 2019, 12:34pm UTC](https://discuss.elastic.co/t/use-phrase-suggester-over-multiple-indices/166956 "2019-02-04T12:34:11Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![jettro](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jettro/32/3418_2.png) [@jettro](https://discuss.elastic.co/u/jettro)\
**Post date:** [February 4, 2019, 12:34pm UTC](https://discuss.elastic.co/t/use-phrase-suggester-over-multiple-indices/166956/1 "2019-02-04T12:34:12Z")

</div>

Hi,  
I am trying to understand what happens in the PhraseSuggester. There is something tricky when working with multiple indices. From my experiments, adding more documents to an index can result in missing suggestions. I can reproduce my example. I have two indices: prod\_1 and prod\_2. I insert only one document in index prod\_1 and three documents in index prod\_2. One of the documents in prod\_2 contains the term **fietsen**. When doing a phrase suggest for **fitsen** I would expect fietsen to be returned as a suggestion. This does work when only searching in the index prod\_2, but it does not work when searching for prod\_\*.

Does someone know if this should work? Check below for the sample code.

```
PUT prod_1
{
  "settings": {
    "number_of_shards": 1,
    "number_of_replicas": 0
  },
  "mappings": {
    "_doc": {
      "properties": {
        "title": {
          "type": "text"
        }
      }
    }
  }
}

PUT prod_2
{
  "settings": {
    "number_of_shards": 1,
    "number_of_replicas": 0
  },
  "mappings": {
    "_doc": {
      "properties": {
        "title": {
          "type": "text"
        }
      }
    }
  }
}

POST _bulk
{"index": {"_index": "prod_1", "_type": "_doc", "_id": 1}}
{"title": "Boek over kinderen"}

POST _bulk
{"index": {"_index": "prod_2", "_type": "_doc", "_id": 8}}
{"title": "Boek over fietsen"}
{"index": {"_index": "prod_2", "_type": "_doc", "_id": 1}}
{"title": "Boek over auto's"}
{"index": {"_index": "prod_2", "_type": "_doc", "_id": 2}}
{"title": "Boek over paarden"}

GET prod_*/_search
{
  "suggest": {
    "content-phrase-suggestion": {
      "text": "fitsen",
      "phrase": {
        "field": "title",
        "size": 10,
        "real_word_error_likelihood": 0.95,
        "confidence": 1,
        "separator": " ",
        "max_errors": 1,
        "force_unigrams": true,
        "token_limit": 10,
        "gram_size": 1,
        "collate": {
          "query": {
            "source": """{"match":{"title":{"query":"{{suggestion}}","operator":"and"}}}""",
            "lang": "mustache"
          },
          "prune": false
        }
      }
    }
  }
}
```

---

<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:** [March 4, 2019, 12:34pm UTC](https://discuss.elastic.co/t/use-phrase-suggester-over-multiple-indices/166956/2 "2019-03-04T12:34:13Z")

</div>

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