How to construct a boolquery dynamically in java api?

more specifically, I want to accomplish the following lucene code in ES.

BooleanQuery booleanQuery = new BooleanQuery();
booleanQuery.add(query1, BooleanClause.Occur.SHOULD);
booleanQuery.add(query2, BooleanClause.Occur.SHOULD);

On Monday, April 1, 2013 7:26:26 PM UTC+8, Jingang Wang wrote:

Hi there,

In my program, I generated a list of termQuery dynamically and I want to
combine them into a boolquery. How could I implement it in java api? Thanks.
By the way, I want to accomplish the fuction as follows:

QueryBuilder qb = QueryBuilders
.boolQuery()
.must(matchPhraseQuery("body", "some text"))
.should(termQuery1)
.should(termQuery2)
.....
.should(termQueryN);

--
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.
For more options, visit https://groups.google.com/groups/opt_out.