How to implement JSON for searching data from elasticsearch


(smhdiu) #1

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

--


(David Pilato) #2

Have a look here: https://github.com/elasticsearchfr/hands-on

It should help you to start.
Answers are in answers branch: https://github.com/elasticsearchfr/hands-on/tree/answers

HTH

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

Le 1 nov. 2012 à 13:43, mohsin husen 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 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

--

--


(smhdiu) #3

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: https://github.com/elasticsearchfr/hands-on

It should help you to start.
Answers are in answers branch:
https://github.com/elasticsearchfr/hands-on/tree/answers

HTH

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

Le 1 nov. 2012 à 13:43, mohsin husen <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 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

--

--


(David Pilato) #4

Look here: 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: http://www.slideshare.net/mobile/dadoonet/hands-on-lab-elasticsearch
Althought it's in french, you can understand some code.

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

Le 1 nov. 2012 à 15:23, mohsin husen 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: https://github.com/elasticsearchfr/hands-on

It should help you to start.
Answers are in answers branch: https://github.com/elasticsearchfr/hands-on/tree/answers

HTH

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

Le 1 nov. 2012 à 13:43, mohsin husen 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 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

--

--

--


(smhdiu) #5

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
You get all hits and you can use Jackson to deserialize hits to your
javabeans.

See also:
http://www.slideshare.net/mobile/dadoonet/hands-on-lab-elasticsearch
Althought it's in french, you can understand some code.

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

Le 1 nov. 2012 à 15:23, mohsin husen <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: https://github.com/elasticsearchfr/hands-on

It should help you to start.
Answers are in answers branch:
https://github.com/elasticsearchfr/hands-on/tree/answers

HTH

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

Le 1 nov. 2012 à 13:43, mohsin husen 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 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

--

--

--


(system) #6