How to query with JSON when use Java API in ElasticSearch?

Hi all,
I'm using ElasticSearch as a search service in Spring Web project. Now
I'm using Transport Client to communicate with ES.
I'm wondering if there exists a method which can construct a QueryBuilder
from a JSON DSL. for example, convert this bool query DSL JSON
{
"query" : {
"bool" : {
"must" : { "match" : {"content" : "quick"},
"should": { "match": {"content" : "lazy"}
}
}
}

to a QueryBuilder. I need this function because I have to receive 

user's bool string input from web front-side, and parse this bool string to
a QueryBuilder.
However it not suit to use
QueryBuilders.boolQuery().must(matchQB).should(shouldQB).must_not(mustNotQB).
Because we may need several must or non must keywords.

Thanks for your time! I'm really need some help.

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/1a26d1b4-d457-4dbb-b36e-caf469353d55%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Hi,

there are QueryBuilder that can parse JSON, e.g. WrapperQueryBuilder
http://javadoc.kyubu.de/elasticsearch/HEAD/org/elasticsearch/index/query/WrapperQueryBuilder.html wrapperQuery(java.lang.String source).
This should do the job.

Greets,
Andrej

PS: Still wondering why javadocs disappeared a while ago. This would be a
great help if javadocs would be available for each version for download.

Am Montag, 15. September 2014 09:22:45 UTC+2 schrieb 张新星:

Hi all,
I'm using ElasticSearch as a search service in Spring Web project.
Now I'm using Transport Client to communicate with ES.
I'm wondering if there exists a method which can construct a QueryBuilder
from a JSON DSL. for example, convert this bool query DSL JSON
{
"query" : {
"bool" : {
"must" : { "match" : {"content" : "quick"},
"should": { "match": {"content" : "lazy"}
}
}
}

to a QueryBuilder. I need this function because I have to receive 

user's bool string input from web front-side, and parse this bool string to
a QueryBuilder.
However it not suit to use
QueryBuilders.boolQuery().must(matchQB).should(shouldQB).must_not(mustNotQB).
Because we may need several must or non must keywords.

Thanks for your time! I'm really need some help.

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/780122c7-16b2-4f17-9c83-b77a6401e85f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Hi Andrej,
Thanks a lot for your kindly help. It's really give me a big progress.
PS: I also found that QueryBuilders.wrapperQuery(String DSL) can do the
same
work. http://stackoverflow.com/questions/25859921/how-to-construct-querybuilder-from-json-dsl-when-using-java-api-in-elasticsearch

在 2014年9月15日星期一UTC+8下午5时08分10秒,Andrej Rosenheinrich写道:

Hi,

there are QueryBuilder that can parse JSON, e.g. WrapperQueryBuilder
http://javadoc.kyubu.de/elasticsearch/HEAD/org/elasticsearch/index/query/WrapperQueryBuilder.html wrapperQuery(java.lang.String source).
This should do the job.

Greets,
Andrej

PS: Still wondering why javadocs disappeared a while ago. This would be a
great help if javadocs would be available for each version for download.

Am Montag, 15. September 2014 09:22:45 UTC+2 schrieb 张新星:

Hi all,
I'm using ElasticSearch as a search service in Spring Web project.
Now I'm using Transport Client to communicate with ES.
I'm wondering if there exists a method which can construct a QueryBuilder
from a JSON DSL. for example, convert this bool query DSL JSON
{
"query" : {
"bool" : {
"must" : { "match" : {"content" : "quick"},
"should": { "match": {"content" : "lazy"}
}
}
}

to a QueryBuilder. I need this function because I have to receive 

user's bool string input from web front-side, and parse this bool string to
a QueryBuilder.
However it not suit to use
QueryBuilders.boolQuery().must(matchQB).should(shouldQB).must_not(mustNotQB).
Because we may need several must or non must keywords.

Thanks for your time! I'm really need some help.

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/e9593f26-cd85-4162-bb1c-1fedec92caa8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.