Daniel Kobe
Daniel Kobe

Reputation: 9825

Elasticsearch match all except specified fields query, exclude

My indexed Elasticsearch documents include many fields. I've been using match_all query to get results. There are a few fields I'd like to exclude from match_all, is this possible?

Upvotes: 2

Views: 5131

Answers (3)

KARTHEEK GUMMALURI
KARTHEEK GUMMALURI

Reputation: 345

For this question I will give you the example

GET index_name/index_type/_search
{
  "_source": {

  "exclude": [
    ]
  },
  "query": {
    "match_all": {}
  }
}

Upvotes: 1

Christophe Roussy
Christophe Roussy

Reputation: 17049

With ElasticSearch 2.x, you can use source filtering, example:

{
    "_source": {
        "include": [ "obj1.*", "obj2.*" ],
        "exclude": [ "*.description" ]
    },
    "query" : {
        "term" : { "user" : "kimchy" }
    }
}

For a GET request you may also pass it via the url.

Upvotes: 0

chengpohi
chengpohi

Reputation: 14227

In Elasticsearch you can use partial fields to filter fields.

Example:

{
    "query": {
        "match_all": {}
    },
    "partial_fields": {
        "partial1": {
            "exclude": ["excludeField1", "excludeField2"]
        }
    }
}

Upvotes: 0

Related Questions