How to write Filter in JAVA Api?


(Rajnikant) #1

Here My Code is
POST vehicletracking/_search
{
"filter": {
"range": {
"localtimestamp": {
"gte": "2016-02-01",
"lte": "2016-02-05"
}
}
}
}

How to write this code in Java Api?


(David Pilato) #2

Read here: https://www.elastic.co/guide/en/elasticsearch/client/java-api/2.2/java-term-level-queries.html#java-query-dsl-range-query


(Rajnikant) #3

When I use
QueryBuilder qb2 = QueryBuilders.rangeQuery("localtimestamp")
.gte("2016/02/02")
.lte("2016/02/05");

then i get this type of error.
"Failed to execute phase [query], all shards failed; shardFailures".


(David Pilato) #4

Can't tell without details:

Full trace
Actual Mapping


(system) #5