字段(Fields)

Fields

  警告: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选项仅仅leaf字段能返回。因此,对象字段无法返回,并且这样的请求将失败。

  脚本字段也可以自动检测并用作字段,因此,尽管不推荐使用_source.obj1.field1这样的东西,obj1.field1也可以正常使用。

Disable stored fields entirely(完全禁用存储的字段)

  要完全禁用存储的字段(和元数据字段),请使用:\ _none_:

GET /_search
{
    "stored_fields": "_none_",
    "query" : {
        "term" : { "user" : "kimchy" }
    }
}

  注意:如果使用_none_,则_source和version参数无法激活。

 

原文地址:https://www.elastic.co/guide/en/elasticsearch/reference/5.0/search-request-stored-fields.html

posted @ 2017-07-25 16:32  流浪三毛  阅读(1796)  评论(0)    收藏  举报