While querying Elasticsearch, sometimes you might want to exclude certain large fields from the response.
To exclude specific fields in an Elasticsearch query, use source filtering:
GET /_search
{
"_source": {
"exclude": ["description"]
},
"query" : {
"term" : { "country" : "france" }
}
}
You can also do source filtering using a GET
parameter.
curl "localhost:9200/<index>/_doc/1?_source_excludes=description"
NOTE: you can also include only specific fields in a search response.
Elasticsearch can have a steep learning curve. If you're looking for a fast but easier-to-use alternative,
take a look at Typesense.