Search in sources :

Example 1 with LindenRangeFilter

use of com.xiaomi.linden.thrift.common.LindenRangeFilter in project linden by XiaoMi.

the class RangeFilterConstructor method construct.

@Override
protected Filter construct(LindenFilter lindenFilter, LindenConfig config) throws IOException {
    LindenRangeFilter lindenRangeFilter = lindenFilter.getRangeFilter();
    LindenRange range = lindenRangeFilter.getRange();
    LindenType type = range.getType();
    String start = range.getStartValue();
    String end = range.getEndValue();
    String fieldName = range.getField();
    boolean startClose = range.isStartClosed();
    boolean endClose = range.isEndClosed();
    Filter filter = null;
    switch(type) {
        case STRING:
        case FACET:
            filter = new TermRangeFilter(fieldName, bytesRefVal(start), bytesRefVal(end), startClose, endClose);
            break;
        case INTEGER:
            filter = NumericRangeFilter.newIntRange(fieldName, intVal(start), intVal(end), startClose, endClose);
            break;
        case LONG:
            filter = NumericRangeFilter.newLongRange(fieldName, longVal(start), longVal(end), startClose, endClose);
            break;
        case DOUBLE:
            filter = NumericRangeFilter.newDoubleRange(fieldName, doubleVal(start), doubleVal(end), startClose, endClose);
            break;
        case FLOAT:
            filter = NumericRangeFilter.newFloatRange(fieldName, floatVal(start), floatVal(end), startClose, endClose);
            break;
    }
    return filter;
}
Also used : LindenRangeFilter(com.xiaomi.linden.thrift.common.LindenRangeFilter) LindenRangeFilter(com.xiaomi.linden.thrift.common.LindenRangeFilter) LindenFilter(com.xiaomi.linden.thrift.common.LindenFilter) TermRangeFilter(org.apache.lucene.search.TermRangeFilter) Filter(org.apache.lucene.search.Filter) NumericRangeFilter(org.apache.lucene.search.NumericRangeFilter) LindenType(com.xiaomi.linden.thrift.common.LindenType) LindenRange(com.xiaomi.linden.thrift.common.LindenRange) TermRangeFilter(org.apache.lucene.search.TermRangeFilter)

Aggregations

LindenFilter (com.xiaomi.linden.thrift.common.LindenFilter)1 LindenRange (com.xiaomi.linden.thrift.common.LindenRange)1 LindenRangeFilter (com.xiaomi.linden.thrift.common.LindenRangeFilter)1 LindenType (com.xiaomi.linden.thrift.common.LindenType)1 Filter (org.apache.lucene.search.Filter)1 NumericRangeFilter (org.apache.lucene.search.NumericRangeFilter)1 TermRangeFilter (org.apache.lucene.search.TermRangeFilter)1