Wildcard query on _id failing in 6.1.2


(Srikanth Bemineni) #1

Hi,

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*"
                }
            }
}

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


(David Pilato) #2

_id is a special field: https://www.elastic.co/guide/en/elasticsearch/reference/6.2/mapping-id-field.html

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).


(Srikanth Bemineni) #3

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?


(David Pilato) #4

As stated in documentation, wildcard is slow.


(system) #5

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