From eabba0b9d731ea24113ea8f8a360baa1885e36f6 Mon Sep 17 00:00:00 2001 From: Harsha Vamsi Kalluri Date: Fri, 30 Aug 2024 10:23:03 -0400 Subject: [PATCH] Change cacheable to false Signed-off-by: Harsha Vamsi Kalluri --- CHANGELOG.md | 3 --- .../approximate/ApproximatePointRangeQuery.java | 2 +- .../search/approximate/ApproximateScoreQuery.java | 11 +---------- .../approximate/ApproximateScoreQueryTests.java | 2 +- 4 files changed, 3 insertions(+), 15 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index da0196e071635..50486529f1828 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -33,9 +33,6 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), - [Workload Management] Add query group stats constructs ([#15343](https://github.com/opensearch-project/OpenSearch/pull/15343))) - Add runAs to Subject interface and introduce IdentityAwarePlugin extension point ([#14630](https://github.com/opensearch-project/OpenSearch/pull/14630)) - Optimize NodeIndicesStats output behind flag ([#14454](https://github.com/opensearch-project/OpenSearch/pull/14454)) -- [Workload Management] Add rejection logic for co-ordinator and shard level requests ([#15428](https://github.com/opensearch-project/OpenSearch/pull/15428))) -- Adding translog durability validation in index templates ([#15494](https://github.com/opensearch-project/OpenSearch/pull/15494)) -- Add index creation using the context field ([#15290](https://github.com/opensearch-project/OpenSearch/pull/15290)) - [Range Queries] Add new approximateable query framework to short-circuit range queries ([#13788](https://github.com/opensearch-project/OpenSearch/pull/13788)) ### Dependencies diff --git a/server/src/main/java/org/opensearch/search/approximate/ApproximatePointRangeQuery.java b/server/src/main/java/org/opensearch/search/approximate/ApproximatePointRangeQuery.java index ec2c249d77793..cee8bc43d7ffd 100644 --- a/server/src/main/java/org/opensearch/search/approximate/ApproximatePointRangeQuery.java +++ b/server/src/main/java/org/opensearch/search/approximate/ApproximatePointRangeQuery.java @@ -419,7 +419,7 @@ public int count(LeafReaderContext context) throws IOException { @Override public boolean isCacheable(LeafReaderContext ctx) { - return true; + return false; } }; } diff --git a/server/src/main/java/org/opensearch/search/approximate/ApproximateScoreQuery.java b/server/src/main/java/org/opensearch/search/approximate/ApproximateScoreQuery.java index 11fd7a817088a..d1dd32b239f28 100644 --- a/server/src/main/java/org/opensearch/search/approximate/ApproximateScoreQuery.java +++ b/server/src/main/java/org/opensearch/search/approximate/ApproximateScoreQuery.java @@ -12,7 +12,6 @@ import org.apache.lucene.search.IndexSearcher; import org.apache.lucene.search.Query; import org.apache.lucene.search.QueryVisitor; -import org.apache.lucene.search.ScoreMode; import org.apache.lucene.search.Weight; import org.opensearch.search.internal.SearchContext; @@ -42,18 +41,10 @@ public ApproximateQuery getApproximationQuery() { return approximationQuery; } - @Override - public Weight createWeight(IndexSearcher searcher, ScoreMode scoreMode, float boost) throws IOException { - if (resolvedQuery == null) { - throw new IllegalStateException("Cannot create weight without setContext being called"); - } - return resolvedQuery.createWeight(searcher, scoreMode, boost); - } - @Override public final Query rewrite(IndexSearcher indexSearcher) throws IOException { if (resolvedQuery == null) { - throw new IllegalStateException("Cannot create weight without setContext being called"); + throw new IllegalStateException("Cannot rewrite resolved query without setContext being called"); } return resolvedQuery.rewrite(indexSearcher); } diff --git a/server/src/test/java/org/opensearch/search/approximate/ApproximateScoreQueryTests.java b/server/src/test/java/org/opensearch/search/approximate/ApproximateScoreQueryTests.java index 3a1c86c095bed..aa45ea6744227 100644 --- a/server/src/test/java/org/opensearch/search/approximate/ApproximateScoreQueryTests.java +++ b/server/src/test/java/org/opensearch/search/approximate/ApproximateScoreQueryTests.java @@ -66,7 +66,7 @@ protected String toString(int dimension, byte[] value) { try { IndexSearcher searcher = new IndexSearcher(reader); searcher.search(query, 10); - Weight weight = query.createWeight(searcher, ScoreMode.TOP_SCORES, 1.0F); + Weight weight = query.rewrite(searcher).createWeight(searcher, ScoreMode.TOP_SCORES, 1.0F); Scorer scorer = weight.scorer(reader.leaves().get(0)); assertEquals( scorer,