Stored Fields - shuiyuebingdian/ElasticSearch GitHub Wiki
stored_fields参数涉及显式标记为存储在映射中的字段,默认情况下处于关闭状态,通常不建议这样做。而是使用源过滤来选择要返回的原始源文档的子集。
允许有选择地为搜索命中表示的每个文档加载特定的存储字段。
GET /_search
{
"stored_fields" : ["user", "postDate"],
"query" : {
"term" : { "user" : "kimchy" }
}
}
-
可用于从文档加载所有存储的字段。
空数组将仅返回_id与_type,例如:GET /_search { "stored_fields" : [], "query" : { "term" : { "user" : "kimchy" } } } 如果未存储请求的字段(store映射设置为false),则将忽略它们。
从文档本身获取的存储字段值始终以数组形式返回。相反,诸如_routing和_parent的元数据字段从不作为数组返回。
也只能通过该field选项返回叶字段。因此无法返回对象字段,并且此类请求将失败。
脚本字段也可以被自动检测并用作字段,因此_source.obj1.field1可以使用(尽管不建议使用)之类的东西,因为它们 obj1.field1也可以工作。
完全禁用存储的字段
要完全禁用存储的字段(和元数据字段),请使用_none_:
GET /_search
{
"stored_fields": "_none_",
"query" : {
"term" : { "user" : "kimchy" }
}
}
如果使用_none_参数,_source和version将无法激活。