From bae04e6e72d48587ca4dec344518c84597ab66d4 Mon Sep 17 00:00:00 2001 From: Harsha Vamsi Kalluri Date: Thu, 18 Jan 2024 21:24:53 -0800 Subject: [PATCH] Using exact match instead of range Signed-off-by: Harsha Vamsi Kalluri --- .../opensearch/index/mapper/IpFieldMapper.java | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) diff --git a/server/src/main/java/org/opensearch/index/mapper/IpFieldMapper.java b/server/src/main/java/org/opensearch/index/mapper/IpFieldMapper.java index 5941cca8e6395..05bbad5a675c3 100644 --- a/server/src/main/java/org/opensearch/index/mapper/IpFieldMapper.java +++ b/server/src/main/java/org/opensearch/index/mapper/IpFieldMapper.java @@ -40,6 +40,7 @@ import org.apache.lucene.search.MatchNoDocsQuery; import org.apache.lucene.search.PointRangeQuery; import org.apache.lucene.search.Query; +import org.apache.lucene.search.TermQuery; import org.apache.lucene.util.ArrayUtil; import org.apache.lucene.util.BytesRef; import org.opensearch.Version; @@ -244,24 +245,11 @@ public Query termQuery(Object value, @Nullable QueryShardContext context) { if (isSearchable() && hasDocValues()) { return new IndexOrDocValuesQuery( query, - SortedSetDocValuesField.newSlowRangeQuery( - ((PointRangeQuery) query).getField(), - new BytesRef(((PointRangeQuery) query).getLowerPoint()), - new BytesRef(((PointRangeQuery) query).getUpperPoint()), - true, - true - ) + SortedSetDocValuesField.newSlowExactQuery(name(), ((BytesRef) value)) ); } if (hasDocValues()) { - // InetAddressPoint uses a rangeQuery internally for terms - return SortedSetDocValuesField.newSlowRangeQuery( - ((PointRangeQuery) query).getField(), - new BytesRef(((PointRangeQuery) query).getLowerPoint()), - new BytesRef(((PointRangeQuery) query).getUpperPoint()), - true, - true - ); + return SortedSetDocValuesField.newSlowExactQuery(name(), ((BytesRef) value)); } return query; }