是否可以在ElasticSearch中的'_source'中包含'_id'

sha*_*ion 5 elasticsearch

通常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查询这样做.

小智 1

_id 字段既没有索引也没有存储,这意味着它并不真正存在。_type 字段仅被索引,但不被存储。_id和_type都是elasticsearch的matedata,它们连接在一起为id#type(_uid)。