Create java SearchResponse from Json

TLDR: Need to create java SearchResponse out of json string

I'm writing some unit tests in Java and I have a specific json string from a search response (one created in kibana) that I would like to use.

I need to create a SearchResponse (the java object) out of this json so that I can pass it to the same methods that the actual response from the client goes to.

I've tried using a jackson ObjectMapper and calling readValue or convertValue with no luck. From looking at some of the docs I think I need to use an XContentBuilder but I'm struggling to get it to work.

Any help is appreciated.

1 Like

In coming 5.6 and 6.0, you will find I think some fromXContent() methods in the response objects.

I think that shouldn't achieve what you are looking for.

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