Use filter_path in High Level Rest API

(Hatim Stovewala) #1

Saw this post regarding filter_path. I'm aware that Java API does not support Response filtering because it is done on Rest layer and Java API use transport layer. So my question is does High level Rest API support this feature? I think it should support because High level Rest API is based on Rest API as stated in the post but I could not find a way to do that. Please guide me.

(David Pilato) #2

That's a good question/remark.

I think it does not because the objects used in the HLClient are basically the Transport ones.
I did not check though.

@tlrx WDYT? Is this something we could globally add on the HLClient whatever the API is? Like an option for every API?

(Tanguy) #3

No, filter_path is not supported by the high level REST client because it removes parts of the JSON response and there are good chances that it breaks the parsing logic that parse responses to Java objects.

You can still use filter_path with the low-level REST client and parse the response yourself.

(Hatim Stovewala) #4

Thanks for your reply @dadoonet & @tanguy.

I can't use low level rest API because I'm using Elasticsearch's internal Aggregations, Terms, etc API's to parse the data I get from SearchRespone. If I use low level, I won't be able to parse low level response to SearchResponse.

What my desired mechanism would be like I construct a query and a aggregation query. I use Pipeline Aggregations to do some calculations. I just need the Pipeline Aggregation output and not the other Aggregations on which I'm computing. The SearchResponse comes around 10MB+. So, I need to reduce this size and get only the desired Pipeline Aggregations and not the rest not needed Aggregations.

Is there an alternative to do this?

(David Pilato) #5

If I use low level, I won't be able to parse low level response to SearchResponse.

Yes. That's true.
The best option IMO is to parse the Response object (from Low Level client) as a Map and use it then for your use case.

Can't see a better option as parsing back the JSon to a SearchResponse object is probably not doable as you will have filtered a lot of data.

(system) #6

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.