I'm trying to super-optimize somes queries, but when trying to change a RangeQuery on a Date field,
I'm very surprised to do not have a better time using an Integer with TermsQuery.
I have one field: a Date field, lets say "2017-06-01"
I add another field: an Integer field storing only year + month as int : 201706
What we need is to have results having the same year for exemple (sometimes 2 months around a date):
Solution 1°/ (my initial query)
date field + range query like :
.from("2017-06-01||/y") .to("2017-06-01||+1y/y") .includeUpper(false);
integer field + range query like :
.from(201701) .to(201712) .includeUpper(true);
integer field + terms query like :
termsQuery("fieldname", [201701, 201702, 201703, 201704 ... 201712])
None of the three is better than other, very surprised !!!
Any feedback or advice ?