是否可以在ElasticSearch的'_source'中包含'_id' [英] Is it possible to include '_id' in '_source' in ElasticSearch
问题描述
通常ElasticSearch文件存储为:
Usually ElasticSearch documents are stored as:
{
"_index": "some_index",
"_type": "some_type",
"_id": "blah_blah",
"_score": null,
"_source": {
"field_a" : "value_a",
"field_b" : "value_b"
........
}
在查询数据时,是否可以在_source本身中包含_id?例如
Is it possible to include _id in the _source itself while querying the data? e.g.
{
"_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"
........
}
此外,我可以读取整个对象并手动包含它,但是想知道是否有办法通过ES查询来执行。
Let's assume I do not have control over the data I am writing so cannot insert it in the source. Also, I can read the entire object and manually include it but wondering if there is a way to do so via ES query.
推荐答案
_id字段既不被索引也不存储,这意味着它不存在。
_type字段仅被索引,但不存储。 _id和_type都是弹性搜索的mateata,它们连接在一起作为id#type(_uid)。
The _id field is neither indexed nor stored, meaning it dosen't really exist. The _type field is only indexed ,but not stored. _id and _type are both matedata of elasticsearch, they concatenated together as id#type(_uid).
这篇关于是否可以在ElasticSearch的'_source'中包含'_id'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!