Is there a way to exclude a field in an Elasticsearch query

前端 未结 2 1114
清歌不尽
清歌不尽 2020-12-17 09:05

I know to use the fields setting to include just the fields I want in a search http://www.elasticsearch.org/guide/reference/api/search/fields/

... but I was wonderin

2条回答
  •  再見小時候
    2020-12-17 09:30

    Did you see the documentation for ‛partial‛ on the same page you linked in your question? That allows you to do what you want, albeit only on ‛_source‛ fields I believe. See https://www.elastic.co/guide/en/elasticsearch/reference/1.7/search-request-fields.html

    When loading data from _source, partial fields can be used to use wildcards to control what part of the _source will be loaded based on include and exclude patterns.

    Both include and exclude support multiple patterns:

    {
        "query" : {
            "match_all" : {}
        },
        "partial_fields" : {
            "partial1" : {
                "include" : ["obj1.obj2.*", "obj1.obj4.*"],
                "exclude" : "obj1.obj3.*"
            }
        }
    }
    

提交回复
热议问题