use of com.xiaomi.linden.thrift.common.LindenRangeQuery in project linden by XiaoMi.
the class RangeQueryConstructor method construct.
@Override
protected Query construct(LindenQuery lindenQuery, LindenConfig config) throws IOException {
if (lindenQuery.isSetRangeQuery()) {
LindenRangeQuery lindenRangeQuery = lindenQuery.getRangeQuery();
LindenRange range = lindenRangeQuery.getRange();
String fieldName = range.getField();
LindenType type = range.getType();
String start = range.getStartValue();
String end = range.getEndValue();
boolean startClose = range.isStartClosed();
boolean endClose = range.isEndClosed();
Query query = null;
switch(type) {
case STRING:
case FACET:
query = new TermRangeQuery(fieldName, bytesRefVal(start), bytesRefVal(end), startClose, endClose);
break;
case INTEGER:
query = NumericRangeQuery.newIntRange(fieldName, intVal(start), intVal(end), startClose, endClose);
break;
case LONG:
query = NumericRangeQuery.newLongRange(fieldName, longVal(start), longVal(end), startClose, endClose);
break;
case DOUBLE:
query = NumericRangeQuery.newDoubleRange(fieldName, doubleVal(start), doubleVal(end), startClose, endClose);
break;
case FLOAT:
query = NumericRangeQuery.newFloatRange(fieldName, floatVal(start), floatVal(end), startClose, endClose);
break;
}
return query;
}
// todo throw exception.
return null;
}
Aggregations