# Search API by JSON

**URL:** <https://discuss.elastic.co/t/search-api-by-json/143310>\
**Category:** Elasticsearch\
**Created:** [August 7, 2018, 11:23am UTC](https://discuss.elastic.co/t/search-api-by-json/143310 "2018-08-07T11:23:10Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![sarankup](https://avatars.discourse-cdn.com/v4/letter/s/858c86/32.png) [@sarankup](https://discuss.elastic.co/u/sarankup)\
**Post date:** [August 7, 2018, 11:23am UTC](https://discuss.elastic.co/t/search-api-by-json/143310/1 "2018-08-07T11:23:10Z")

</div>

Hi, I have been using Elasticsearch through Java API. In order to _search I send a JSON document to build the search query as follows_

WrapperQueryBuilder WrapperQueryObj = QueryBuilders.wrapperQuery();  
elasticclient.prepareSearch(indexname).setTypes(datatype).setQuery(WrapperQueryObj).setFrom(beginingAt).setSize(doclength).setExplain(true).get();

now, I want to add the SortBuilder. Is there anyway to create a SortBuilder from a JSON String or Array like the Querybuilder? QueryBuilders is awesome which reduces tens of code into one line.

Thanks in advance.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [September 4, 2018, 11:23am UTC](https://discuss.elastic.co/t/search-api-by-json/143310/2 "2018-09-04T11:23:17Z")

</div>

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