Wildcard query on _id failing in 6.1.2


I recently moved from elastic search 5.5 to 6.1.2. After moving to the new version, all elastic search wildcard queries on _id is not returning any hits. This code used to work in 5.5. We verified this using my application as well as kibana. We have also taken care of having only one type mapping "doc" in a single index.

POST group_topic/doc/_search
  "query":{"wildcard": {
                  "_id": "g*"

"took": 0,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"skipped": 0,
"failed": 0
"hits": {
"total": 0,
"max_score": null,
"hits": []

_id is a special field: _id field | Elasticsearch Reference [6.2] | Elastic

You can't search in it like any normal field. Just few queries are supported.

If your use case requires to wildcard search on it (bad idea BTW), then you need to use one of the supported queries:

The value of the _id field is accessible in certain queries (term, terms, match, query_string, simple_query_string).

I will try to change it, by moving this into one of the mapping fields. The same query was working using _uid instead of _id in 5.5. Was there any change in 6.x? which affected this query.

Can you please explain me why is this a bad idea ?. Is this going to affect any performance?

As stated in documentation, wildcard is slow.

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