user555303
user555303

Reputation: 1364

Need to return source fields only, without any metadata - how to use plugin?

We have a requirement that we return just the source fields in search results, without any of the metadata. From searching, I gather that this is not possible with elasticsearch, but I did find a reference to maybe using a plugin in this thread:

Filter out metadata fields and only return source fields in elasticsearch

The plugin that was linked was this one:

https://github.com/imotov/elasticsearch-just-source/blob/master/src/main/java/org/elasticsearch/examples/justsource/rest/action/RestJustSourceAction.java

I'm still learning about elasticsearch, but can someone explain how I would implement and deploy that plugin in our elasticsearch configuration?

Thanks, Jim

Upvotes: 6

Views: 2878

Answers (1)

Val
Val

Reputation: 217344

As stated in the first link you referenced, it is possible to do it with response filtering which is not a plugin but a standard feature of ES:

GET /index/type/_search?filter_path=hits.hits._source

If you want to get rid of hits.hits._source you can use jq

curl -XGET localhost:9200/index/type/_search?filter_path=hits.hits._source | jq '.hits.hits[]._source'

Upvotes: 5

Related Questions