List of usage examples for org.apache.lucene.document NumericDocValuesField newSlowRangeQuery
public static Query newSlowRangeQuery(String field, long lowerValue, long upperValue)
From source file:org.apache.solr.schema.EnumFieldType.java
License:Apache License
@Override public Query getRangeQuery(QParser parser, SchemaField field, String min, String max, boolean minInclusive, boolean maxInclusive) { Integer minValue = enumMapping.stringValueToIntValue(min); Integer maxValue = enumMapping.stringValueToIntValue(max); if (field.indexed()) { BytesRef minBytes = null;/*from w w w .ja v a 2s.c o m*/ if (min != null) { byte[] bytes = new byte[Integer.BYTES]; NumericUtils.intToSortableBytes(minValue, bytes, 0); minBytes = new BytesRef(bytes); } BytesRef maxBytes = null; if (max != null) { byte[] bytes = new byte[Integer.BYTES]; NumericUtils.intToSortableBytes(maxValue, bytes, 0); maxBytes = new BytesRef(bytes); } return new TermRangeQuery(field.getName(), minBytes, maxBytes, minInclusive, maxInclusive); } else { long lowerValue = Long.MIN_VALUE; long upperValue = Long.MAX_VALUE; if (minValue != null) { lowerValue = minValue.longValue(); if (minInclusive == false) { ++lowerValue; } } if (maxValue != null) { upperValue = maxValue.longValue(); if (maxInclusive == false) { --upperValue; } } if (field.multiValued()) { return new ConstantScoreQuery( SortedNumericDocValuesField.newSlowRangeQuery(field.getName(), lowerValue, upperValue)); } else { return new ConstantScoreQuery( NumericDocValuesField.newSlowRangeQuery(field.getName(), lowerValue, upperValue)); } } }