Use phrase suggester over multiple indices

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
        }
      }
    }
  }
}
1 Like

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