# From json string to SearchResponse object

**URL:** <https://discuss.elastic.co/t/from-json-string-to-searchresponse-object/8575>\
**Category:** Elasticsearch\
**Created:** [July 31, 2012, 10:47am UTC](https://discuss.elastic.co/t/from-json-string-to-searchresponse-object/8575 "2012-07-31T10:47:43Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Aykut\_Uysal](https://avatars.discourse-cdn.com/v4/letter/a/f17d59/32.png) [@Aykut\_Uysal](https://discuss.elastic.co/u/Aykut_Uysal)\
**Post date:** [July 31, 2012, 10:47am UTC](https://discuss.elastic.co/t/from-json-string-to-searchresponse-object/8575/1 "2012-07-31T10:47:43Z")

</div>

Hello all,

I'm querying elasticsearch through its rest interface and getting a  
json result. I wonder if there is a common way to map returning json  
string into SearchResponse object which is available in Java API.

I've found SearchResponse.readFromResponse() and readFrom() methods.  
So far I couldn't make them work and while doing some research I've  
also found kimchy saying 'There is no way to parse a json to a  
SearchResponse' in this thread :  
[http://elasticsearch-users.115913.n3.nabble.com/From-JSON-to-Java-API-and-back-td2655285.html](http://elasticsearch-users.115913.n3.nabble.com/From-JSON-to-Java-API-and-back-td2655285.html)

Can someone clarify this issue for me?

Thank you  
aykut

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [July 31, 2012, 12:29pm UTC](https://discuss.elastic.co/t/from-json-string-to-searchresponse-object/8575/2 "2012-07-31T12:29:41Z")

</div>

I don't understand.  
Why don't you use Search Java API directly ?

David 😉  
Twitter : @dadoonet / @elasticsearchfr

Le 31 juil. 2012 à 12:47, Aykut Uysal [aykutuysal@gmail.com](mailto:aykutuysal@gmail.com) a écrit :

> Hello all,
> 
> I'm querying elasticsearch through its rest interface and getting a  
> json result. I wonder if there is a common way to map returning json  
> string into SearchResponse object which is available in Java API.
> 
> I've found SearchResponse.readFromResponse() and readFrom() methods.  
> So far I couldn't make them work and while doing some research I've  
> also found kimchy saying 'There is no way to parse a json to a  
> SearchResponse' in this thread :  
> [http://elasticsearch-users.115913.n3.nabble.com/From-JSON-to-Java-API-and-back-td2655285.html](http://elasticsearch-users.115913.n3.nabble.com/From-JSON-to-Java-API-and-back-td2655285.html)
> 
> Can someone clarify this issue for me?
> 
> Thank you  
> aykut

---

<div class="post-metadata">

**Author:** ![Aykut\_Uysal](https://avatars.discourse-cdn.com/v4/letter/a/f17d59/32.png) [@Aykut\_Uysal](https://discuss.elastic.co/u/Aykut_Uysal)\
**Post date:** [July 31, 2012, 1:09pm UTC](https://discuss.elastic.co/t/from-json-string-to-searchresponse-object/8575/3 "2012-07-31T13:09:24Z")

</div>

Decision of using REST is made a little time ago. It's part of a large  
project and I'm doing some research about mapping options. I just  
wondered if there is a way to use Java API domain objects like  
SearchResponse for mapping the response json since it already has the  
structure that we need.

On Tue, Jul 31, 2012 at 3:29 PM, David Pilato [david@pilato.fr](mailto:david@pilato.fr) wrote:

> I don't understand.  
> Why don't you use Search Java API directly ?
> 
> David 😉  
> Twitter : @dadoonet / @elasticsearchfr
> 
> Le 31 juil. 2012 à 12:47, Aykut Uysal [aykutuysal@gmail.com](mailto:aykutuysal@gmail.com) a écrit :
> 
> > Hello all,
> > 
> > I'm querying elasticsearch through its rest interface and getting a  
> > json result. I wonder if there is a common way to map returning json  
> > string into SearchResponse object which is available in Java API.
> > 
> > I've found SearchResponse.readFromResponse() and readFrom() methods.  
> > So far I couldn't make them work and while doing some research I've  
> > also found kimchy saying 'There is no way to parse a json to a  
> > SearchResponse' in this thread :  
> > [http://elasticsearch-users.115913.n3.nabble.com/From-JSON-to-Java-API-and-back-td2655285.html](http://elasticsearch-users.115913.n3.nabble.com/From-JSON-to-Java-API-and-back-td2655285.html)
> > 
> > Can someone clarify this issue for me?
> > 
> > Thank you  
> > aykut

---

<div class="post-metadata">

**Author:** ![ferhatsb](https://avatars.discourse-cdn.com/v4/letter/f/977dab/32.png) [@ferhatsb](https://discuss.elastic.co/u/ferhatsb)\
**Post date:** [August 20, 2012, 1:52pm UTC](https://discuss.elastic.co/t/from-json-string-to-searchresponse-object/8575/4 "2012-08-20T13:52:55Z")

</div>

Hi Aykut,

We are working on a rest client based on Java. It has it's own API and also  
it has a bridge that can be plugged to native Java API, so you can use it  
as is over a rest endpoint.

BUT it is not ready for production though give us some weeks it will be  
alpha 🙂

Checkout source code you will find some tricks about your question.

> **[GitHub - searchbox-io/Jest: Elasticsearch Java Rest Client.](https://github.com/searchbox-io/Jest)**
>
> Elasticsearch Java Rest Client. Contribute to searchbox-io/Jest development by creating an account on GitHub.

KR,

Ferhat  
[www.searchbox.io](http://www.searchbox.io)

On Tuesday, July 31, 2012 4:09:24 PM UTC+3, Aykut Uysal wrote:

> Decision of using REST is made a little time ago. It's part of a large  
> project and I'm doing some research about mapping options. I just  
> wondered if there is a way to use Java API domain objects like  
> SearchResponse for mapping the response json since it already has the  
> structure that we need.
> 
> On Tue, Jul 31, 2012 at 3:29 PM, David Pilato \<[da...@pilato.fr](mailto:da...@pilato.fr)\<javascript:\>\>  
> wrote:
> 
> > I don't understand.  
> > Why don't you use Search Java API directly ?
> > 
> > David 😉  
> > Twitter : @dadoonet / @elasticsearchfr
> > 
> > Le 31 juil. 2012 à 12:47, Aykut Uysal \<[aykut...@gmail.com](mailto:aykut...@gmail.com) \<javascript:\>\>  
> > a écrit :
> > 
> > > Hello all,
> > > 
> > > I'm querying elasticsearch through its rest interface and getting a  
> > > json result. I wonder if there is a common way to map returning json  
> > > string into SearchResponse object which is available in Java API.
> > > 
> > > I've found SearchResponse.readFromResponse() and readFrom() methods.  
> > > So far I couldn't make them work and while doing some research I've  
> > > also found kimchy saying 'There is no way to parse a json to a  
> > > SearchResponse' in this thread :
> 
> [http://elasticsearch-users.115913.n3.nabble.com/From-JSON-to-Java-API-and-back-td2655285.html](http://elasticsearch-users.115913.n3.nabble.com/From-JSON-to-Java-API-and-back-td2655285.html)
> 
> > > Can someone clarify this issue for me?
> > > 
> > > Thank you  
> > > aykut

--

---

<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:** [July 6, 2017, 3:15am UTC](https://discuss.elastic.co/t/from-json-string-to-searchresponse-object/8575/5 "2017-07-06T03:15:47Z")

</div>


