Using Java API to create a query


(spokarna) #1

Hi All,

I am attempting to write a parser that will help me to translate a simple query language into ElasticSearch objects.

I am not how to do this for a query like
source=file && ip=127.0.0.1 AND (timestamp between xxx and yyy)

I want to pass the object to the search method. What are the builder objects that I should be using?

For a simple expression
source=file AND (timestamp between xxx and yyy)
I can do this:
qb = QueryBuilders.filteredQuery
(termQuery(key, value),
rangeFilter("timestamp").from(this.getStartTime()).to(this.getEndTime()));

Thanks and regards,
Sameer


(system) #2