# How to implement JSON for searching data from elasticsearch

**URL:** <https://discuss.elastic.co/t/how-to-implement-json-for-searching-data-from-elasticsearch/9517>\
**Category:** Elasticsearch\
**Created:** [November 1, 2012, 12:43pm UTC](https://discuss.elastic.co/t/how-to-implement-json-for-searching-data-from-elasticsearch/9517 "2012-11-01T12:43:04Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![smhdiu](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/smhdiu/32/1808_2.png) [@smhdiu](https://discuss.elastic.co/u/smhdiu)\
**Post date:** [November 1, 2012, 12:43pm UTC](https://discuss.elastic.co/t/how-to-implement-json-for-searching-data-from-elasticsearch/9517/1 "2012-11-01T12:43:04Z")

</div>

Hello all,

i am new to elasticsearch and lucene.

i have following json string that i want to get parse from elastic search.

{  
"fields": [  
"email",  
"firstName",  
"lastName"  
],

"query": {  
"query\_string": {  
"fields": [  
"email","firstName","email"  
],  
"query": "Jelena @gmail.com",  
"use\_dis\_max": true  
}  
}  
}

just want to know the method to pass this string to java api.  
any sample code in java api will be much appreciated.

Thanks in advanced  
Mohsin

--

---

<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:** [November 1, 2012, 1:36pm UTC](https://discuss.elastic.co/t/how-to-implement-json-for-searching-data-from-elasticsearch/9517/2 "2012-11-01T13:36:07Z")

</div>

Have a look here: [GitHub - elasticsearchfr/hands-on: Hands On Lab](https://github.com/elasticsearchfr/hands-on)

It should help you to start.  
Answers are in answers branch: [GitHub - elasticsearchfr/hands-on at answers](https://github.com/elasticsearchfr/hands-on/tree/answers)

HTH

--  
David 😉  
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs

Le 1 nov. 2012 à 13:43, mohsin husen [smhdiu@gmail.com](mailto:smhdiu@gmail.com) a écrit :

> Hello all,
> 
> i am new to elasticsearch and lucene.
> 
> i have following json string that i want to get parse from Elasticsearch.
> 
> {  
> "fields": [  
> "email",  
> "firstName",  
> "lastName"  
> ],
> 
> "query": {  
> "query\_string": {  
> "fields": [  
> "email","firstName","email"  
> ],  
> "query": "Jelena @gmail.com",  
> "use\_dis\_max": true  
> }  
> }  
> }
> 
> just want to know the method to pass this string to java api.  
> any sample code in java api will be much appreciated.
> 
> Thanks in advanced  
> Mohsin
> 
> --

--

---

<div class="post-metadata">

**Author:** ![smhdiu](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/smhdiu/32/1808_2.png) [@smhdiu](https://discuss.elastic.co/u/smhdiu)\
**Post date:** [November 1, 2012, 2:23pm UTC](https://discuss.elastic.co/t/how-to-implement-json-for-searching-data-from-elasticsearch/9517/3 "2012-11-01T14:23:59Z")

</div>

That helped me a lot.  
Thanks David.

i now know how to search the data.  
now once i have the SearchResponce how can i get my fields?  
i.e can i get a list of values ?

thanks in adavnced  
mohsin

On Thursday, 1 November 2012 13:36:18 UTC, David Pilato wrote:

> Have a look here: [GitHub - elasticsearchfr/hands-on: Hands On Lab](https://github.com/elasticsearchfr/hands-on)
> 
> It should help you to start.  
> Answers are in answers branch:  
> [GitHub - elasticsearchfr/hands-on at answers](https://github.com/elasticsearchfr/hands-on/tree/answers)
> 
> HTH
> 
> --  
> David 😉  
> Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs
> 
> Le 1 nov. 2012 à 13:43, mohsin husen \<[smh...@gmail.com](mailto:smh...@gmail.com) \<javascript:\>\> a  
> écrit :
> 
> Hello all,
> 
> i am new to elasticsearch and lucene.
> 
> i have following json string that i want to get parse from Elasticsearch.
> 
> {  
> "fields": [  
> "email",  
> "firstName",  
> "lastName"  
> ],
> 
> "query": {  
> "query\_string": {  
> "fields": [  
> "email","firstName","email"  
> ],  
> "query": "Jelena @gmail.com",  
> "use\_dis\_max": true  
> }  
> }  
> }
> 
> just want to know the method to pass this string to java api.  
> any sample code in java api will be much appreciated.
> 
> Thanks in advanced  
> Mohsin
> 
> --

--

---

<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:** [November 1, 2012, 2:43pm UTC](https://discuss.elastic.co/t/how-to-implement-json-for-searching-data-from-elasticsearch/9517/4 "2012-11-01T14:43:06Z")

</div>

Look here: [https://github.com/elasticsearchfr/hands-on/blob/answers/src/test/java/org/elasticsearchfr/handson/ex2/SearchTest.java#L268](https://github.com/elasticsearchfr/hands-on/blob/answers/src/test/java/org/elasticsearchfr/handson/ex2/SearchTest.java#L268)  
You get all hits and you can use Jackson to deserialize hits to your javabeans.

See also: [Hands on lab Elasticsearch | PPT](http://www.slideshare.net/mobile/dadoonet/hands-on-lab-elasticsearch)  
Althought it's in french, you can understand some code.

--  
David 😉  
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs

Le 1 nov. 2012 à 15:23, mohsin husen [smhdiu@gmail.com](mailto:smhdiu@gmail.com) a écrit :

That helped me a lot.  
Thanks David.

i now know how to search the data.  
now once i have the SearchResponce how can i get my fields?  
i.e can i get a list of values ?

thanks in adavnced  
mohsin

On Thursday, 1 November 2012 13:36:18 UTC, David Pilato wrote:

> Have a look here: [GitHub - elasticsearchfr/hands-on: Hands On Lab](https://github.com/elasticsearchfr/hands-on)
> 
> It should help you to start.  
> Answers are in answers branch: [GitHub - elasticsearchfr/hands-on at answers](https://github.com/elasticsearchfr/hands-on/tree/answers)
> 
> HTH
> 
> --  
> David 😉  
> Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs
> 
> Le 1 nov. 2012 à 13:43, mohsin husen [smh...@gmail.com](mailto:smh...@gmail.com) a écrit :
> 
> > Hello all,
> > 
> > i am new to elasticsearch and lucene.
> > 
> > i have following json string that i want to get parse from Elasticsearch.
> > 
> > {  
> > "fields": [  
> > "email",  
> > "firstName",  
> > "lastName"  
> > ],
> > 
> > "query": {  
> > "query\_string": {  
> > "fields": [  
> > "email","firstName","email"  
> > ],  
> > "query": "Jelena @gmail.com",  
> > "use\_dis\_max": true  
> > }  
> > }  
> > }
> > 
> > just want to know the method to pass this string to java api.  
> > any sample code in java api will be much appreciated.
> > 
> > Thanks in advanced  
> > Mohsin
> > 
> > --

--

--

---

<div class="post-metadata">

**Author:** ![smhdiu](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/smhdiu/32/1808_2.png) [@smhdiu](https://discuss.elastic.co/u/smhdiu)\
**Post date:** [November 1, 2012, 4:17pm UTC](https://discuss.elastic.co/t/how-to-implement-json-for-searching-data-from-elasticsearch/9517/5 "2012-11-01T16:17:43Z")

</div>

It has answer to all my question  
Cheers !  
Thanks a ton David !

Mohsin

On Thursday, 1 November 2012 14:43:15 UTC, David Pilato wrote:

> Look here:  
> [https://github.com/elasticsearchfr/hands-on/blob/answers/src/test/java/org/elasticsearchfr/handson/ex2/SearchTest.java#L268](https://github.com/elasticsearchfr/hands-on/blob/answers/src/test/java/org/elasticsearchfr/handson/ex2/SearchTest.java#L268)  
> You get all hits and you can use Jackson to deserialize hits to your  
> javabeans.
> 
> See also:  
> [Hands on lab Elasticsearch | PPT](http://www.slideshare.net/mobile/dadoonet/hands-on-lab-elasticsearch)  
> Althought it's in french, you can understand some code.
> 
> --  
> David 😉  
> Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs
> 
> Le 1 nov. 2012 à 15:23, mohsin husen \<[smh...@gmail.com](mailto:smh...@gmail.com) \<javascript:\>\> a  
> écrit :
> 
> That helped me a lot.  
> Thanks David.
> 
> i now know how to search the data.  
> now once i have the SearchResponce how can i get my fields?  
> i.e can i get a list of values ?
> 
> thanks in adavnced  
> mohsin
> 
> On Thursday, 1 November 2012 13:36:18 UTC, David Pilato wrote:
> 
> > Have a look here: [GitHub - elasticsearchfr/hands-on: Hands On Lab](https://github.com/elasticsearchfr/hands-on)
> > 
> > It should help you to start.  
> > Answers are in answers branch:  
> > [GitHub - elasticsearchfr/hands-on at answers](https://github.com/elasticsearchfr/hands-on/tree/answers)
> > 
> > HTH
> > 
> > --  
> > David 😉  
> > Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs
> > 
> > Le 1 nov. 2012 à 13:43, mohsin husen [smh...@gmail.com](mailto:smh...@gmail.com) a écrit :
> > 
> > Hello all,
> > 
> > i am new to elasticsearch and lucene.
> > 
> > i have following json string that i want to get parse from Elasticsearch.
> > 
> > {  
> > "fields": [  
> > "email",  
> > "firstName",  
> > "lastName"  
> > ],
> > 
> > "query": {  
> > "query\_string": {  
> > "fields": [  
> > "email","firstName","email"  
> > ],  
> > "query": "Jelena @gmail.com",  
> > "use\_dis\_max": true  
> > }  
> > }  
> > }
> > 
> > just want to know the method to pass this string to java api.  
> > any sample code in java api will be much appreciated.
> > 
> > Thanks in advanced  
> > Mohsin
> > 
> > --
> > 
> > --

--

---

<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:06am UTC](https://discuss.elastic.co/t/how-to-implement-json-for-searching-data-from-elasticsearch/9517/6 "2017-07-06T03:06:33Z")

</div>


