# Search query over multiple indices find no hits when suggestions fail

**URL:** <https://discuss.elastic.co/t/search-query-over-multiple-indices-find-no-hits-when-suggestions-fail/129621>\
**Category:** Elasticsearch\
**Created:** [April 26, 2018, 9:07am UTC](https://discuss.elastic.co/t/search-query-over-multiple-indices-find-no-hits-when-suggestions-fail/129621 "2018-04-26T09:07:06Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![PatrickK](https://avatars.discourse-cdn.com/v4/letter/p/ee59a6/32.png) [@PatrickK](https://discuss.elastic.co/u/PatrickK)\
**Post date:** [April 26, 2018, 9:07am UTC](https://discuss.elastic.co/t/search-query-over-multiple-indices-find-no-hits-when-suggestions-fail/129621/1 "2018-04-26T09:07:07Z")

</div>

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

```auto
PUT /test1
{
    "mappings": {
        "default": {
            "properties": {
                "field1": {
                    "type": "text"
                }
            }
        }
    }
}

PUT /test2
{
    "mappings": {
        "default": {
            "properties": {
                "field2": {
                    "type": "text"
                }
            }
        }
    }
}

```

1. Add something to the indices

```auto
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

```auto
POST /_search
{
    "query": {
        "match": {
            "field2": {
                "query": "FOOBARD",
                "fuzziness": 2
            }
        }
    }
}

```

1. But when I add the suggest to the query

```auto
 {
    "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:

```auto
{
    ...
    "_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.

---

<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:** [May 24, 2018, 9:15am UTC](https://discuss.elastic.co/t/search-query-over-multiple-indices-find-no-hits-when-suggestions-fail/129621/2 "2018-05-24T09:15:16Z")

</div>

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