Search query over multiple indices find no hits when suggestions fail

Hello everybody!

A (admittedly very) quick search of the forum, did not yield a result, so I hope this is not an already answered question.

I have several indices with different fields, and while a request containing just a search query yields the expected results, I get no hits when I combine the query with a suggest part which does not work for the index containing the hit (because the field references in the suggest is not present there).

The actual query in question is a multi_match across several fields an quite complex, but I could reproduce my problem with the following example.

  1. Create two indices with different fields
PUT /test1
{
    "mappings": {
        "default": {
            "properties": {
                "field1": {
                    "type": "text"
                }
            }
        }
    }
}

PUT /test2
{
    "mappings": {
        "default": {
            "properties": {
                "field2": {
                    "type": "text"
                }
            }
        }
    }
}
  1. Add something to the indices
PUT /test1/default?refresh=true
{
    "field1": "DEADBEEF in index 1"
}

PUT /test2/default?refresh=true
{
    "field2": "FOOBARDOO in index 2"
}
  1. Searching for FOOBARD in field2 yields the expected result from index test2
POST /_search
{
    "query": {
        "match": {
            "field2": {
                "query": "FOOBARD",
                "fuzziness": 2
            }
        }
    }
}
  1. But when I add the suggest to the query
 {
    "query": {
        "match": {
            "field2": {
                "query": "FOOBARD",
                "fuzziness": 2
            }
        }
    },
    "suggest": {
        "text": "FOOBARD",
        "suggest-field1": {
            "term": {
                "field": "field1"
            }
        }
    }
}

I get a failure message about the missing mapping, and zero search hits:

{
    ...
    "_shards": {
        ...
        "failures": [
            {
                "shard": 0,
                "index": "test2",
                "node": "TGUboSt9SweF3KQBKnoVSg",
                "reason": {
                    "type": "illegal_argument_exception",
                    "reason": "no mapping found for field [field1]"
                }
            }
        ]
    },
    "hits": {
        "total": 0,
        "max_score": null,
        "hits": []
    },
    ...
}

Is this expected behaviour when looking for suggestions over multiple indices, or am I doing something wrong here? I would like to avoid making two queries, which would differ just in the suggestion part.

Any hints and pointers are highly appreciated.

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