我正在尝试为Elasticsearch 6.7创建映射,但是当我获得记录时,除非启用_source,否则我看不到任何映射的字段。
我有以下示例:
PUT xyz
{
"mappings":{
"_doc":{
"_source": {
"enabled": false
},
"properties":{
"raw":{
"type": "text",
"store": true
}
}
}
}
}
PUT xyz/_doc/123
{"raw":"hello"}
GET xyz/_doc/123
但是
GET
的结果是:{
"_index": "xyz",
"_type": "_doc",
"_id": "123",
"_version": 1,
"found": true
}
我的期望是得到的结果包括要存储的字段,但是显然我遗漏了什么?:
{
"_index": "xyz",
"_type": "_doc",
"_id": "123",
"_version": 1,
"found": true,
"raw": "hello"
}
最佳答案
您仍然需要请求要查看的stored fields,如下所示:
GET xyz/_doc/123?stored_fields=raw
然后您会看到以下内容:
{
"_index" : "xyz",
"_type" : "_doc",
"_id" : "123",
"_version" : 1,
"_seq_no" : 0,
"_primary_term" : 1,
"found" : true,
"fields" : {
"raw" : [
"hello"
]
}
}
关于elasticsearch - _source.enabled = false时无法查看结果中的指定字段,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55437454/