Build Query based on Json using Java client

I have some written Json queries and I would like to execute them using the Java client.

The below requires me to break the json in individual parts and pass it in as arguments.

client.prepareSearch(index).setTypes(type).setSearchType(SearchType.DEFAULT).setQuery(query).addSort("myfield", SortOrder.ASC).setScroll(new TimeValue(60000)).setSize(10000).execute().actionGet()

for Instance setQuery() only takes the query portion, then addSort fields 1 by 1, same for fields.

Can we simply read a Json document from file into a String and pass the whole thing through.

you can use wrapperQuery https://github.com/elastic/elasticsearch/blob/master/core/src/test/java/org/elasticsearch/search/query/SearchQueryTests.java#L834-L847

hth