FacetRangeFilter doesn't support empty string

Description

SELECT * FROM SENSEI WHERE cellphone < '' AND lbsRegTime > '1390554357137' AND sex = 'M' LIMIT 0, 100 ORDER BY lbsRegTime DESC ROUTE BY '144641646'

In this case we expect 0 docs since all string should be bigger or equal then emptry string, but it returns all docs contain cellphone field.

Looked into the code, in RangeFilterConstructor.java

if (facetHandler != null) {
StringBuilder sb = new StringBuilder();
if (include_lower && from != null && from.length() != 0) sb.append("[");
else sb.append("(");

if (from == null || from.length() == 0) sb.append("*");
else sb.append(from);
sb.append(" TO ");
if (to == null || to.length() == 0) sb.append("*");
else sb.append(to);

if (include_upper && to != null && to.length() != 0) sb.append("]");
else sb.append(")");
RandomAccessFilter filter = null;
;
Object facetData = boboReader.getFacetData(field);
// If it's Sensei's standard facet handler
if (facetData instanceof FacetDataCache) {
filter = new FacetRangeFilter(facetHandler, sb.toString());
} else {
filter = facetHandler.buildRandomAccessFilter(sb.toString(), null);
}
return filter.getDocIdSet(context, acceptDocs);
}

So the filter both < '' and > '' are translated to (* to *) , since from and to is null or empty.
And if the filter is (* to *) it return all docs except those docs don't contain this term.

Environment

None

Status

Assignee

Yonghui Zhao

Reporter

Yonghui Zhao

Labels

None

Priority

Major
Configure