Building queries on the fly with java 1.7 api

Hi folks

I'd like to do something like this on the fly:

select * from index where (fld1 < 4) and (fld2 == "a") or ( (fld3 < "b") and (fld3 > "d"))

where I'm given the names of the fields and the values.

I think I've got to use QueryFilters in some way but can't find any examples.

Can someone me out?

Hi,

if you don't need scoring of your results, you basically want to combine two AndFilters containing RangeFilter and maybe a TermFilter for the string equality. The you put those into an OrFilter. Or simply use two BoolFilters (about some of the differences see this old topic
The building blocks should all be here: https://www.elastic.co/guide/en/elasticsearch/client/java-api/1.7/query-dsl-filters.html

Most filters can be created using FilterBuilders, the methods you use to set the parameters largely correpond to the Query DSL. That said, as soon as you switch to ES 2.0, there are going to be changes regarding the use of filters, since they are merged with queries. There's some general overview here.