Java High Level REST Client : How to remove _type,_id,_index from hits[]

(smis) #1


I am using Java High Level REST Client to get the data. I used the Search api to get the response.
My response has hits arrays. and each hit contains the _type,_id,_index,_score fields.Actually I don't want these field to appear in my response.

Please let me know how to achieve this using High Level REST Client api.

My response look like as

"hits": [
"_index": "stratosevents",
"_type": "doc",
"_id": "45e8af72-bf3f-4ebc-8197-bfcc4ba90f57-cisco",
"_score": 1.0909792,
"_source": {
"field": true,

            **"_index":** "stratosevents",
            **"_type":** "doc",
            **"_id":** "b75bfd4f-896b-40d7-af9f-ed92a96a904a-smm-sj12-ij1",
            **"_score":** 1.0909792,
            "_source": {
                "field": true,

Here I don't want to get this _index, _type,_id and _score fields in response.

Please suggest .

(smis) #2

Also let me know if this can be done via Low level rest client.

(David Pilato) #3

Do you mean that you are sending back the json response as is to your users or to the frontend?

(smis) #4

Yes. We want to send it to frontend.

Please suggest.

(David Pilato) #5

You can not do that.