Allow fuzzy IP matches to accept a long min_similarity.

This commit is contained in:
Erick Tryzelaar 2011-06-09 16:15:23 -07:00 committed by kimchy
parent a7013da782
commit 112935fcdb
1 changed files with 10 additions and 1 deletions

View File

@ -178,7 +178,16 @@ public class IpFieldMapper extends NumberFieldMapper<Long> {
@Override public Query fuzzyQuery(String value, String minSim, int prefixLength, int maxExpansions) {
long iValue = ipToLong(value);
long iSim = ipToLong(minSim);
long iSim;
try {
iSim = ipToLong(minSim);
} catch (ElasticSearchIllegalArgumentException e) {
try {
iSim = Long.parseLong(minSim);
} catch (NumberFormatException e1) {
iSim = (long) Double.parseDouble(minSim);
}
}
return NumericRangeQuery.newLongRange(names.indexName(), precisionStep,
iValue - iSim,
iValue + iSim,