通常ElasticSearch文档存储为:
{
"_index": "some_index",
"_type": "some_type",
"_id": "blah_blah",
"_score": null,
"_source": {
"field_a" : "value_a",
"field_b" : "value_b"
........
}
Run Code Online (Sandbox Code Playgroud)
在查询数据时是否可以在_source本身中包含_id?例如
{
"_index": "some_index",
"_type": "some_type",
"_id": "blah_blah",
"_score": null,
"_source": {
"_id": "blah_blah", // Added in the _source object
"field_a" : "value_a",
"field_b" : "value_b"
........
}
Run Code Online (Sandbox Code Playgroud)
假设我无法控制我正在编写的数据,因此无法将其插入源代码中.此外,我可以读取整个对象并手动包含它,但想知道是否有办法通过ES查询这样做.