val = val.substring(1, val.length() - 1);
int index1 = val.indexOf(" ");
if (index1 < 0)
throw new IllegalStateException("couldn't handle filter " + key + ":" + val);
RangeFilterBuilder rfb = FilterBuilders.rangeFilter(key);
Object from = null;
Object to = null;
if (!val.startsWith("*") && !val.startsWith("-Infinity")) {
try {
from = Integer.parseInt(val.substring(0, index1));
} catch (NumberFormatException ex) {
from = Helper.toDate(val.substring(0, index1));
}
rfb.from(from).includeLower(true);
}
if (!val.endsWith("*") && !val.endsWith("Infinity")) {
String tmp = val.substring(index1 + " TO ".length());
try {
to = Integer.parseInt(tmp);
} catch (NumberFormatException ex) {
to = Helper.toDate(tmp);
}
if (from != null)
rfb.to(to).includeUpper(true);
else
rfb.lte(to);
}
if (from == null && to == null)
return FilterBuilders.existsFilter(val);