Java Code Examples for org.apache.lucene.search.NumericRangeQuery

The following examples show how to use org.apache.lucene.search.NumericRangeQuery. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
@Override
public void addQueryTerms(BooleanQuery query, AdvancedSearchParams params) {
    try {
        ZipscriptQueryParams queryParams = params.getExtensionData(ZipscriptQueryParams.ZIPSCRIPTQUERYPARAMS);
        if (queryParams.getMinPresent() != null || queryParams.getMaxPresent() != null) {
            Query presentQuery = NumericRangeQuery.newIntRange("present",
                    queryParams.getMinPresent(), queryParams.getMaxPresent(), true, true);
            query.add(presentQuery, Occur.MUST);
        }
        if (queryParams.getMinMissing() != null || queryParams.getMaxMissing() != null) {
            Query missingQuery = NumericRangeQuery.newIntRange("missing",
                    queryParams.getMinMissing(), queryParams.getMaxMissing(), true, true);
            query.add(missingQuery, Occur.MUST);
        }
        if (queryParams.getMinPercent() != null || queryParams.getMaxPercent() != null) {
            Query percentQuery = NumericRangeQuery.newIntRange("percent",
                    queryParams.getMinPercent(), queryParams.getMaxPercent(), true, true);
            query.add(percentQuery, Occur.MUST);
        }
    } catch (KeyNotFoundException e) {
        // No MP3 terms to include, return without amending query
    }
}
 
Example 2
@Override
public void addQueryTerms(BooleanQuery query, AdvancedSearchParams params) {
    try {
        ZipscriptQueryParams queryParams = params.getExtensionData(ZipscriptQueryParams.ZIPSCRIPTQUERYPARAMS);
        if (queryParams.getMinPresent() != null || queryParams.getMaxPresent() != null) {
            Query presentQuery = NumericRangeQuery.newIntRange("present",
                    queryParams.getMinPresent(), queryParams.getMaxPresent(), true, true);
            query.add(presentQuery, Occur.MUST);
        }
        if (queryParams.getMinMissing() != null || queryParams.getMaxMissing() != null) {
            Query missingQuery = NumericRangeQuery.newIntRange("missing",
                    queryParams.getMinMissing(), queryParams.getMaxMissing(), true, true);
            query.add(missingQuery, Occur.MUST);
        }
        if (queryParams.getMinPercent() != null || queryParams.getMaxPercent() != null) {
            Query percentQuery = NumericRangeQuery.newIntRange("percent",
                    queryParams.getMinPercent(), queryParams.getMaxPercent(), true, true);
            query.add(percentQuery, Occur.MUST);
        }
    } catch (KeyNotFoundException e) {
        // No MP3 terms to include, return without amending query
    }
}
 
Example 3
Source Project: stratio-cassandra   Source File: TokenMapperMurmur.java    License: Apache License 2.0 6 votes vote down vote up
/** {@inheritDoc} */
@Override
protected Query makeQuery(Token lower, Token upper, boolean includeLower, boolean includeUpper) {
    Long start = lower == null ? null : (Long) lower.getTokenValue();
    Long stop = upper == null ? null : (Long) upper.getTokenValue();
    if (lower != null && lower.isMinimum()) {
        start = null;
    }
    if (upper != null && upper.isMinimum()) {
        stop = null;
    }
    if (start == null && stop == null) {
        return null;
    }
    return NumericRangeQuery.newLongRange(FIELD_NAME, start, stop, includeLower, includeUpper);
}
 
Example 4
Source Project: stratio-cassandra   Source File: MatchConditionTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void testInteger() {

    Map<String, ColumnMapper> map = new HashMap<>();
    map.put("name", new ColumnMapperInteger(1f));
    Schema mappers = new Schema(map, null, EnglishAnalyzer.class.getName());

    MatchCondition matchCondition = new MatchCondition(0.5f, "name", 42);
    Query query = matchCondition.query(mappers);

    Assert.assertNotNull(query);
    Assert.assertEquals(NumericRangeQuery.class, query.getClass());
    Assert.assertEquals(42, ((NumericRangeQuery<?>) query).getMin());
    Assert.assertEquals(42, ((NumericRangeQuery<?>) query).getMax());
    Assert.assertEquals(true, ((NumericRangeQuery<?>) query).includesMin());
    Assert.assertEquals(true, ((NumericRangeQuery<?>) query).includesMax());
    Assert.assertEquals(0.5f, query.getBoost(), 0);
}
 
Example 5
Source Project: stratio-cassandra   Source File: MatchConditionTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void testLong() {

    Map<String, ColumnMapper> map = new HashMap<>();
    map.put("name", new ColumnMapperLong(1f));
    Schema mappers = new Schema(map, null, EnglishAnalyzer.class.getName());

    MatchCondition matchCondition = new MatchCondition(0.5f, "name", 42L);
    Query query = matchCondition.query(mappers);

    Assert.assertNotNull(query);
    Assert.assertEquals(NumericRangeQuery.class, query.getClass());
    Assert.assertEquals(42L, ((NumericRangeQuery<?>) query).getMin());
    Assert.assertEquals(42L, ((NumericRangeQuery<?>) query).getMax());
    Assert.assertEquals(true, ((NumericRangeQuery<?>) query).includesMin());
    Assert.assertEquals(true, ((NumericRangeQuery<?>) query).includesMax());
    Assert.assertEquals(0.5f, query.getBoost(), 0);
}
 
Example 6
Source Project: stratio-cassandra   Source File: MatchConditionTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void testFloat() {

    Map<String, ColumnMapper> map = new HashMap<>();
    map.put("name", new ColumnMapperFloat(1f));
    Schema mappers = new Schema(map, null, EnglishAnalyzer.class.getName());

    MatchCondition matchCondition = new MatchCondition(0.5f, "name", 42.42F);
    Query query = matchCondition.query(mappers);

    Assert.assertNotNull(query);
    Assert.assertEquals(NumericRangeQuery.class, query.getClass());
    Assert.assertEquals(42.42F, ((NumericRangeQuery<?>) query).getMin());
    Assert.assertEquals(42.42F, ((NumericRangeQuery<?>) query).getMax());
    Assert.assertEquals(true, ((NumericRangeQuery<?>) query).includesMin());
    Assert.assertEquals(true, ((NumericRangeQuery<?>) query).includesMax());
    Assert.assertEquals(0.5f, query.getBoost(), 0);
}
 
Example 7
Source Project: stratio-cassandra   Source File: MatchConditionTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void testDouble() {

    Map<String, ColumnMapper> map = new HashMap<>();
    map.put("name", new ColumnMapperDouble(1f));
    Schema mappers = new Schema(map, null, EnglishAnalyzer.class.getName());

    MatchCondition matchCondition = new MatchCondition(0.5f, "name", 42.42D);
    Query query = matchCondition.query(mappers);

    Assert.assertNotNull(query);
    Assert.assertEquals(NumericRangeQuery.class, query.getClass());
    Assert.assertEquals(42.42D, ((NumericRangeQuery<?>) query).getMin());
    Assert.assertEquals(42.42D, ((NumericRangeQuery<?>) query).getMax());
    Assert.assertEquals(true, ((NumericRangeQuery<?>) query).includesMin());
    Assert.assertEquals(true, ((NumericRangeQuery<?>) query).includesMax());
    Assert.assertEquals(0.5f, query.getBoost(), 0);
}
 
Example 8
Source Project: stratio-cassandra   Source File: RangeConditionTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void testIntegerClose() {

    Map<String, ColumnMapper> map = new HashMap<>();
    map.put("name", new ColumnMapperInteger(1f));
    Schema mappers = new Schema(map, null, EnglishAnalyzer.class.getName());

    RangeCondition rangeCondition = new RangeCondition(0.5f, "name", 42, 43, false, false);
    Query query = rangeCondition.query(mappers);

    Assert.assertNotNull(query);
    Assert.assertEquals(NumericRangeQuery.class, query.getClass());
    Assert.assertEquals("name", ((NumericRangeQuery<?>) query).getField());
    Assert.assertEquals(42, ((NumericRangeQuery<?>) query).getMin());
    Assert.assertEquals(43, ((NumericRangeQuery<?>) query).getMax());
    Assert.assertEquals(false, ((NumericRangeQuery<?>) query).includesMin());
    Assert.assertEquals(false, ((NumericRangeQuery<?>) query).includesMax());
    Assert.assertEquals(0.5f, query.getBoost(), 0);
}
 
Example 9
Source Project: stratio-cassandra   Source File: RangeConditionTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void testIntegerOpen() {

    Map<String, ColumnMapper> map = new HashMap<>();
    map.put("name", new ColumnMapperInteger(1f));
    Schema mappers = new Schema(map, null, EnglishAnalyzer.class.getName());

    RangeCondition rangeCondition = new RangeCondition(0.5f, "name", 42, null, true, false);
    Query query = rangeCondition.query(mappers);

    Assert.assertNotNull(query);
    Assert.assertEquals(NumericRangeQuery.class, query.getClass());
    Assert.assertEquals("name", ((NumericRangeQuery<?>) query).getField());
    Assert.assertEquals(42, ((NumericRangeQuery<?>) query).getMin());
    Assert.assertEquals(null, ((NumericRangeQuery<?>) query).getMax());
    Assert.assertEquals(true, ((NumericRangeQuery<?>) query).includesMin());
    Assert.assertEquals(false, ((NumericRangeQuery<?>) query).includesMax());
    Assert.assertEquals(0.5f, query.getBoost(), 0);
}
 
Example 10
Source Project: stratio-cassandra   Source File: RangeConditionTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void testLongClose() {

    Map<String, ColumnMapper> map = new HashMap<>();
    map.put("name", new ColumnMapperLong(1f));
    Schema mappers = new Schema(map, null, EnglishAnalyzer.class.getName());

    RangeCondition rangeCondition = new RangeCondition(0.5f, "name", 42L, 43, false, false);
    Query query = rangeCondition.query(mappers);

    Assert.assertNotNull(query);
    Assert.assertEquals(NumericRangeQuery.class, query.getClass());
    Assert.assertEquals("name", ((NumericRangeQuery<?>) query).getField());
    Assert.assertEquals(42L, ((NumericRangeQuery<?>) query).getMin());
    Assert.assertEquals(43L, ((NumericRangeQuery<?>) query).getMax());
    Assert.assertEquals(false, ((NumericRangeQuery<?>) query).includesMin());
    Assert.assertEquals(false, ((NumericRangeQuery<?>) query).includesMax());
    Assert.assertEquals(0.5f, query.getBoost(), 0);
}
 
Example 11
Source Project: stratio-cassandra   Source File: RangeConditionTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void testLongOpen() {

    Map<String, ColumnMapper> map = new HashMap<>();
    map.put("name", new ColumnMapperLong(1f));
    Schema mappers = new Schema(map, null, EnglishAnalyzer.class.getName());

    RangeCondition rangeCondition = new RangeCondition(0.5f, "name", 42f, null, true, false);
    Query query = rangeCondition.query(mappers);

    Assert.assertNotNull(query);
    Assert.assertEquals(NumericRangeQuery.class, query.getClass());
    Assert.assertEquals("name", ((NumericRangeQuery<?>) query).getField());
    Assert.assertEquals(42L, ((NumericRangeQuery<?>) query).getMin());
    Assert.assertEquals(null, ((NumericRangeQuery<?>) query).getMax());
    Assert.assertEquals(true, ((NumericRangeQuery<?>) query).includesMin());
    Assert.assertEquals(false, ((NumericRangeQuery<?>) query).includesMax());
    Assert.assertEquals(0.5f, query.getBoost(), 0);
}
 
Example 12
Source Project: stratio-cassandra   Source File: RangeConditionTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void testFloatClose() {

    Map<String, ColumnMapper> map = new HashMap<>();
    map.put("name", new ColumnMapperFloat(1f));
    Schema mappers = new Schema(map, null, EnglishAnalyzer.class.getName());

    RangeCondition rangeCondition = new RangeCondition(0.5f, "name", 42.42D, 43.42F, false, false);
    Query query = rangeCondition.query(mappers);

    Assert.assertNotNull(query);
    Assert.assertEquals(NumericRangeQuery.class, query.getClass());
    Assert.assertEquals("name", ((NumericRangeQuery<?>) query).getField());
    Assert.assertEquals(42.42F, ((NumericRangeQuery<?>) query).getMin());
    Assert.assertEquals(43.42f, ((NumericRangeQuery<?>) query).getMax());
    Assert.assertEquals(false, ((NumericRangeQuery<?>) query).includesMin());
    Assert.assertEquals(false, ((NumericRangeQuery<?>) query).includesMax());
    Assert.assertEquals(0.5f, query.getBoost(), 0);
}
 
Example 13
Source Project: stratio-cassandra   Source File: RangeConditionTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void testFloatOpen() {

    Map<String, ColumnMapper> map = new HashMap<>();
    map.put("name", new ColumnMapperFloat(1f));
    Schema mappers = new Schema(map, null, EnglishAnalyzer.class.getName());

    RangeCondition rangeCondition = new RangeCondition(0.5f, "name", 42.42f, null, true, false);
    Query query = rangeCondition.query(mappers);

    Assert.assertNotNull(query);
    Assert.assertEquals(NumericRangeQuery.class, query.getClass());
    Assert.assertEquals("name", ((NumericRangeQuery<?>) query).getField());
    Assert.assertEquals(42.42f, ((NumericRangeQuery<?>) query).getMin());
    Assert.assertEquals(null, ((NumericRangeQuery<?>) query).getMax());
    Assert.assertEquals(true, ((NumericRangeQuery<?>) query).includesMin());
    Assert.assertEquals(false, ((NumericRangeQuery<?>) query).includesMax());
    Assert.assertEquals(0.5f, query.getBoost(), 0);
}
 
Example 14
Source Project: stratio-cassandra   Source File: RangeConditionTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void testDoubleClose() {

    Map<String, ColumnMapper> map = new HashMap<>();
    map.put("name", new ColumnMapperDouble(1f));
    Schema mappers = new Schema(map, null, EnglishAnalyzer.class.getName());

    RangeCondition rangeCondition = new RangeCondition(0.5f, "name", 42.42D, 43.42D, false, false);
    Query query = rangeCondition.query(mappers);

    Assert.assertNotNull(query);
    Assert.assertEquals(NumericRangeQuery.class, query.getClass());
    Assert.assertEquals("name", ((NumericRangeQuery<?>) query).getField());
    Assert.assertEquals(42.42D, ((NumericRangeQuery<?>) query).getMin());
    Assert.assertEquals(43.42D, ((NumericRangeQuery<?>) query).getMax());
    Assert.assertEquals(false, ((NumericRangeQuery<?>) query).includesMin());
    Assert.assertEquals(false, ((NumericRangeQuery<?>) query).includesMax());
    Assert.assertEquals(0.5f, query.getBoost(), 0);
}
 
Example 15
Source Project: stratio-cassandra   Source File: RangeConditionTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void testDoubleOpen() {

    Map<String, ColumnMapper> map = new HashMap<>();
    map.put("name", new ColumnMapperDouble(1f));
    Schema mappers = new Schema(map, null, EnglishAnalyzer.class.getName());

    RangeCondition rangeCondition = new RangeCondition(0.5f, "name", 42.42D, null, true, false);
    Query query = rangeCondition.query(mappers);

    Assert.assertNotNull(query);
    Assert.assertEquals(NumericRangeQuery.class, query.getClass());
    Assert.assertEquals("name", ((NumericRangeQuery<?>) query).getField());
    Assert.assertEquals(42.42D, ((NumericRangeQuery<?>) query).getMin());
    Assert.assertEquals(null, ((NumericRangeQuery<?>) query).getMax());
    Assert.assertEquals(true, ((NumericRangeQuery<?>) query).includesMin());
    Assert.assertEquals(false, ((NumericRangeQuery<?>) query).includesMax());
    Assert.assertEquals(0.5f, query.getBoost(), 0);
}
 
Example 16
Source Project: localization_nifi   Source File: LuceneUtil.java    License: Apache License 2.0 5 votes vote down vote up
public static org.apache.lucene.search.Query convertQuery(final org.apache.nifi.provenance.search.Query query) {
    if (query.getStartDate() == null && query.getEndDate() == null && query.getSearchTerms().isEmpty()) {
        return new MatchAllDocsQuery();
    }

    final BooleanQuery luceneQuery = new BooleanQuery();
    for (final SearchTerm searchTerm : query.getSearchTerms()) {
        final String searchValue = searchTerm.getValue();
        if (searchValue == null) {
            throw new IllegalArgumentException("Empty search value not allowed (for term '" + searchTerm.getSearchableField().getFriendlyName() + "')");
        }

        if (searchValue.contains("*") || searchValue.contains("?")) {
            luceneQuery.add(new BooleanClause(new WildcardQuery(new Term(searchTerm.getSearchableField().getSearchableFieldName(), searchTerm.getValue().toLowerCase())), Occur.MUST));
        } else {
            luceneQuery.add(new BooleanClause(new TermQuery(new Term(searchTerm.getSearchableField().getSearchableFieldName(), searchTerm.getValue().toLowerCase())), Occur.MUST));
        }
    }

    final Long minBytes = query.getMinFileSize() == null ? null : DataUnit.parseDataSize(query.getMinFileSize(), DataUnit.B).longValue();
    final Long maxBytes = query.getMaxFileSize() == null ? null : DataUnit.parseDataSize(query.getMaxFileSize(), DataUnit.B).longValue();
    if (minBytes != null || maxBytes != null) {
        luceneQuery.add(NumericRangeQuery.newLongRange(SearchableFields.FileSize.getSearchableFieldName(), minBytes, maxBytes, true, true), Occur.MUST);
    }

    final Long minDateTime = query.getStartDate() == null ? null : query.getStartDate().getTime();
    final Long maxDateTime = query.getEndDate() == null ? null : query.getEndDate().getTime();
    if (maxDateTime != null || minDateTime != null) {
        luceneQuery.add(NumericRangeQuery.newLongRange(SearchableFields.EventTime.getSearchableFieldName(), minDateTime, maxDateTime, true, true), Occur.MUST);
    }

    return luceneQuery;
}
 
Example 17
Source Project: Elasticsearch   Source File: IpFieldMapper.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public Query rangeQuery(Object lowerTerm, Object upperTerm, boolean includeLower, boolean includeUpper) {
    return NumericRangeQuery.newLongRange(names().indexName(), numericPrecisionStep(),
        lowerTerm == null ? null : parseValue(lowerTerm),
        upperTerm == null ? null : parseValue(upperTerm),
        includeLower, includeUpper);
}
 
Example 18
Source Project: Elasticsearch   Source File: IpFieldMapper.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public Query fuzzyQuery(Object value, Fuzziness fuzziness, int prefixLength, int maxExpansions, boolean transpositions) {
    long iValue = parseValue(value);
    long iSim;
    try {
        iSim = ipToLong(fuzziness.asString());
    } catch (IllegalArgumentException e) {
        iSim = fuzziness.asLong();
    }
    return NumericRangeQuery.newLongRange(names().indexName(), numericPrecisionStep(),
        iValue - iSim,
        iValue + iSim,
        true, true);
}
 
Example 19
Source Project: Elasticsearch   Source File: DateFieldMapper.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public Query fuzzyQuery(Object value, Fuzziness fuzziness, int prefixLength, int maxExpansions, boolean transpositions) {
    long iValue = parseValue(value);
    long iSim;
    try {
        iSim = fuzziness.asTimeValue().millis();
    } catch (Exception e) {
        // not a time format
        iSim =  fuzziness.asLong();
    }
    return NumericRangeQuery.newLongRange(names().indexName(), numericPrecisionStep(),
        iValue - iSim,
        iValue + iSim,
        true, true);
}
 
Example 20
Source Project: Elasticsearch   Source File: ShortFieldMapper.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public Query rangeQuery(Object lowerTerm, Object upperTerm, boolean includeLower, boolean includeUpper) {
    return NumericRangeQuery.newIntRange(names().indexName(), numericPrecisionStep(),
        lowerTerm == null ? null : (int)parseValue(lowerTerm),
        upperTerm == null ? null : (int)parseValue(upperTerm),
        includeLower, includeUpper);
}
 
Example 21
Source Project: Elasticsearch   Source File: ShortFieldMapper.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public Query fuzzyQuery(Object value, Fuzziness fuzziness, int prefixLength, int maxExpansions, boolean transpositions) {
    short iValue = parseValue(value);
    short iSim = fuzziness.asShort();
    return NumericRangeQuery.newIntRange(names().indexName(), numericPrecisionStep(),
        iValue - iSim,
        iValue + iSim,
        true, true);
}
 
Example 22
Source Project: Elasticsearch   Source File: FloatFieldMapper.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public Query rangeQuery(Object lowerTerm, Object upperTerm, boolean includeLower, boolean includeUpper) {
    return NumericRangeQuery.newFloatRange(names().indexName(), numericPrecisionStep(),
        lowerTerm == null ? null : parseValue(lowerTerm),
        upperTerm == null ? null : parseValue(upperTerm),
        includeLower, includeUpper);
}
 
Example 23
Source Project: Elasticsearch   Source File: FloatFieldMapper.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public Query fuzzyQuery(Object value, Fuzziness fuzziness, int prefixLength, int maxExpansions, boolean transpositions) {
    float iValue = parseValue(value);
    final float iSim = fuzziness.asFloat();
    return NumericRangeQuery.newFloatRange(names().indexName(), numericPrecisionStep(),
        iValue - iSim,
        iValue + iSim,
        true, true);
}
 
Example 24
Source Project: Elasticsearch   Source File: DoubleFieldMapper.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public Query rangeQuery(Object lowerTerm, Object upperTerm, boolean includeLower, boolean includeUpper) {
    return NumericRangeQuery.newDoubleRange(names().indexName(), numericPrecisionStep(),
        lowerTerm == null ? null : parseDoubleValue(lowerTerm),
        upperTerm == null ? null : parseDoubleValue(upperTerm),
        includeLower, includeUpper);
}
 
Example 25
Source Project: Elasticsearch   Source File: DoubleFieldMapper.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public Query fuzzyQuery(Object value, Fuzziness fuzziness, int prefixLength, int maxExpansions, boolean transpositions) {
    double iValue = parseDoubleValue(value);
    double iSim = fuzziness.asDouble();
    return NumericRangeQuery.newDoubleRange(names().indexName(), numericPrecisionStep(),
        iValue - iSim,
        iValue + iSim,
        true, true);
}
 
Example 26
Source Project: Elasticsearch   Source File: IntegerFieldMapper.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public Query rangeQuery(Object lowerTerm, Object upperTerm, boolean includeLower, boolean includeUpper) {
    return NumericRangeQuery.newIntRange(names().indexName(), numericPrecisionStep(),
        lowerTerm == null ? null : parseValue(lowerTerm),
        upperTerm == null ? null : parseValue(upperTerm),
        includeLower, includeUpper);
}
 
Example 27
Source Project: Elasticsearch   Source File: IntegerFieldMapper.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public Query fuzzyQuery(Object value, Fuzziness fuzziness, int prefixLength, int maxExpansions, boolean transpositions) {
    int iValue = parseValue(value);
    int iSim = fuzziness.asInt();
    return NumericRangeQuery.newIntRange(names().indexName(), numericPrecisionStep(),
        iValue - iSim,
        iValue + iSim,
        true, true);
}
 
Example 28
Source Project: Elasticsearch   Source File: ByteFieldMapper.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public Query rangeQuery(Object lowerTerm, Object upperTerm, boolean includeLower, boolean includeUpper) {
    return NumericRangeQuery.newIntRange(names().indexName(), numericPrecisionStep(),
        lowerTerm == null ? null : (int)parseValue(lowerTerm),
        upperTerm == null ? null : (int)parseValue(upperTerm),
        includeLower, includeUpper);
}
 
Example 29
Source Project: Elasticsearch   Source File: ByteFieldMapper.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public Query fuzzyQuery(Object value, Fuzziness fuzziness, int prefixLength, int maxExpansions, boolean transpositions) {
    byte iValue = parseValue(value);
    byte iSim = fuzziness.asByte();
    return NumericRangeQuery.newIntRange(names().indexName(), numericPrecisionStep(),
        iValue - iSim,
        iValue + iSim,
        true, true);
}
 
Example 30
Source Project: Elasticsearch   Source File: LongFieldMapper.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public Query rangeQuery(Object lowerTerm, Object upperTerm, boolean includeLower, boolean includeUpper) {
    return NumericRangeQuery.newLongRange(names().indexName(), numericPrecisionStep(),
        lowerTerm == null ? null : parseLongValue(lowerTerm),
        upperTerm == null ? null : parseLongValue(upperTerm),
        includeLower, includeUpper);
}