From 513feb8104a8734b90cd2a10b1b38a980e9dcd3d 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 --- CHANGELOG.md | 3 +-- .../opensearch/index/mapper/IpFieldMapper.java | 18 +++--------------- 2 files changed, 4 insertions(+), 17 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 407de9309a4d9..cfbe9bdc0cc01 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -184,8 +184,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), - Add telemetry tracer/metric enable flag and integ test. ([#10395](https://github.com/opensearch-project/OpenSearch/pull/10395)) - Performance improvement for Datetime field caching ([#4558](https://github.com/opensearch-project/OpenSearch/issues/4558)) - Add instrumentation for indexing in transport bulk action and transport shard bulk action. ([#10273](https://github.com/opensearch-project/OpenSearch/pull/10273)) -- Disallow removing some metadata fields by remove ingest processor ([#10895](https://github.com/opensearch-project/OpenSearch/pull/10895), [ -- #11607](https://github.com/opensearch-project/OpenSearch/pull/11607)) +- Disallow removing some metadata fields by remove ingest processor ([#10895](https://github.com/opensearch-project/OpenSearch/pull/10895), [#11607](https://github.com/opensearch-project/OpenSearch/pull/11607)) - Performance improvement for MultiTerm Queries on Keyword fields ([#7057](https://github.com/opensearch-project/OpenSearch/issues/7057)) - Refactor common parts from the Rounding class into a separate 'round' package ([#11023](https://github.com/opensearch-project/OpenSearch/issues/11023)) - Performance improvement for date histogram aggregations without sub-aggregations ([#11083](https://github.com/opensearch-project/OpenSearch/pull/11083)) 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; }