Java Code Examples for org.elasticsearch.common.unit.Fuzziness#asLong()

The following examples show how to use org.elasticsearch.common.unit.Fuzziness#asLong() . 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
Source File: IpFieldMapper.java    From Elasticsearch with 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 2
Source File: DateFieldMapper.java    From Elasticsearch with 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 3
Source File: LongFieldMapper.java    From Elasticsearch with 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 = parseLongValue(value);
    final long iSim = fuzziness.asLong();
    return NumericRangeQuery.newLongRange(names().indexName(), numericPrecisionStep(),
        iValue - iSim,
        iValue + iSim,
        true, true);
}