Skip to content

_id field not returned consistently via Fields API #94515

@cbuescher

Description

@cbuescher

Elasticsearch Version

8.6.2

Installed Plugins

No response

Java Version

Oracle Corporation/Java HotSpot(TM) 64-Bit Server VM/18.0.2/18.0.2+9-61

OS Version

Mac OS X/12.6.3/aarch64

Problem Description

The fields option lets you query the
metadata _id field, but this field doesn't seem to be returned consistently over larger search result sets.

Steps to Reproduce

add several small documents to a test index with e.g.

POST /test/_doc { "foo" : "bar" } 

then query e.g. top 10 docs disabling _source and querying _id via fields:

GET test/_search { "_source": false, "fields": [ "_id" ], "size": 10, "query": { "match_all": {} } } 

In my current reproduction on 8.6.2 this returns e.g.

 "hits": [ { "_index": "test", "_id": "082y5YYBJUrNWn3IOYNS", "_score": 1, "fields": { "_id": [ "082y5YYBJUrNWn3IOYNS" ] } }, { "_index": "test", "_id": "1M2y5YYBJUrNWn3IQIOO", "_score": 1, "fields": { "_id": [ "1M2y5YYBJUrNWn3IQIOO" ] } }, { "_index": "test", "_id": "1c2y5YYBJUrNWn3IRYNb", "_score": 1, "fields": { "_id": [ "1c2y5YYBJUrNWn3IRYNb" ] } }, { "_index": "test", "_id": "1s2y5YYBJUrNWn3ITIMM", "_score": 1, "fields": { "_id": [ "1s2y5YYBJUrNWn3ITIMM" ] } }, { "_index": "test", "_id": "182y5YYBJUrNWn3IUIPe", "_score": 1, "fields": { "_id": [ "182y5YYBJUrNWn3IUIPe" ] } }, { "_index": "test", "_id": "2M2z5YYBJUrNWn3IN4O4", "_score": 1, "fields": { "_id": [ "2M2z5YYBJUrNWn3IN4O4" ] } }, { "_index": "test", "_id": "2c2z5YYBJUrNWn3IUoNm", "_score": 1 }, { "_index": "test", "_id": "2s2z5YYBJUrNWn3IVYOr", "_score": 1 }, { "_index": "test", "_id": "282z5YYBJUrNWn3IWYNq", "_score": 1 }, { "_index": "test", "_id": "3M2z5YYBJUrNWn3IW4P9", "_score": 1, "fields": { "_id": [ "3M2z5YYBJUrNWn3IW4P9" ] } } 

Notice hits 7-9 without the _id field. If queried directly, these documents show the field though:

GET test/_search { "_source": false, "fields": [ "_id" ], "size": 10, "query": { "match": { "_id" : "282z5YYBJUrNWn3IWYNq" } } } ---> "hits": [ { "_index": "test", "_id": "282z5YYBJUrNWn3IWYNq", "_score": 1, "fields": { "_id": [ "282z5YYBJUrNWn3IWYNq" ] } } ] 

Strangely, also changing the "size" seems to change which docs have the _id in the fields response and which don't.

Logs (if relevant)

No response

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions