源过滤(Source filtering)
Source filtering
允许控制每次命中返回_source字段的方式。
默认情况下,除非您使用stored_fields参数或_source字段被禁用,操作将返回_source字段的内容。
您可以使用_source参数关闭_source检索:
要禁用_source检索设置为false:
GET /_search { "_source": false, "query" : { "term" : { "user" : "kimchy" } } }
_source还接受一个或多个通配符模式来控制_source的哪些部分应该返回:
例如:
GET /_search { "_source": "obj.*", "query" : { "term" : { "user" : "kimchy" } } }
或
GET /_search { "_source": [ "obj1.*", "obj2.*" ], "query" : { "term" : { "user" : "kimchy" } } }
最后,为了完全控制,您可以指定includes
和excludes模式:
GET /_search { "_source": { "includes": [ "obj1.*", "obj2.*" ], "excludes": [ "*.description" ] }, "query" : { "term" : { "user" : "kimchy" } } }
原文地址:https://www.elastic.co/guide/en/elasticsearch/reference/5.0/search-request-source-filtering.html