1
votes

I am using elastic search to index data stored in my cassandra cluster.While fetching one record from Elastric Search cluster using the below query,

GET investhry/user/1/_source

I get the below result:

  {
  "password": "$2a$10$mE.qmcV0mFU5NcKh73TZx.z4ueI/.bDWbj0T1BYyqP481kGGarKLG",
  "lang_key": "en",
  "id": "1",
  "login": "system",
  "email": "[email protected]",
  "authorities": [
    "ROLE_ADMIN",
    "ROLE_USER"
  ],
  "lastname": "System",
  "activated": true
}

ie. only the data from _source

But while fetching all the data using this query

 GET investhry/user/_search
       {
      "query": {
     "match_all": {}
     }
   }

I am getting the whole response whereas I just want the _source element.

Can anyone help me with the query or method to get only the _source element with match-all query.

1

1 Answers

1
votes

You can use the filter_path parameter:

GET my_index/my_doctype/_search?filter_path=hits.hits._source

Here we only want to keep the field _source.

https://www.elastic.co/guide/en/elasticsearch/reference/current/common-options.html#common-options-response-filtering