diff --git a/buildSrc/version.properties b/buildSrc/version.properties index 386457146685f..914bae4d2c871 100644 --- a/buildSrc/version.properties +++ b/buildSrc/version.properties @@ -1,5 +1,5 @@ elasticsearch = 7.0.0-alpha1 -lucene = 8.0.0-snapshot-4d78db26be +lucene = 8.0.0-snapshot-66c671ea80 # optional dependencies spatial4j = 0.7 diff --git a/modules/lang-expression/licenses/lucene-expressions-8.0.0-snapshot-4d78db26be.jar.sha1 b/modules/lang-expression/licenses/lucene-expressions-8.0.0-snapshot-4d78db26be.jar.sha1 deleted file mode 100644 index bec50d36793d8..0000000000000 --- a/modules/lang-expression/licenses/lucene-expressions-8.0.0-snapshot-4d78db26be.jar.sha1 +++ /dev/null @@ -1 +0,0 @@ -5f469e925dde5dff81b9d56f465a8babb56cd26b \ No newline at end of file diff --git a/modules/lang-expression/licenses/lucene-expressions-8.0.0-snapshot-66c671ea80.jar.sha1 b/modules/lang-expression/licenses/lucene-expressions-8.0.0-snapshot-66c671ea80.jar.sha1 new file mode 100644 index 0000000000000..047bca7b614bf --- /dev/null +++ b/modules/lang-expression/licenses/lucene-expressions-8.0.0-snapshot-66c671ea80.jar.sha1 @@ -0,0 +1 @@ +58b9db095c569b4c4da491810f14e1429878b594 \ No newline at end of file diff --git a/modules/lang-expression/src/main/java/org/elasticsearch/script/expression/ExpressionScriptEngine.java b/modules/lang-expression/src/main/java/org/elasticsearch/script/expression/ExpressionScriptEngine.java index 23dc0fd276cbe..55f8deb059293 100644 --- a/modules/lang-expression/src/main/java/org/elasticsearch/script/expression/ExpressionScriptEngine.java +++ b/modules/lang-expression/src/main/java/org/elasticsearch/script/expression/ExpressionScriptEngine.java @@ -26,7 +26,7 @@ import org.apache.lucene.index.LeafReaderContext; import org.apache.lucene.queries.function.ValueSource; import org.apache.lucene.queries.function.valuesource.DoubleConstValueSource; -import org.apache.lucene.search.Scorer; +import org.apache.lucene.search.Scorable; import org.apache.lucene.search.SortField; import org.elasticsearch.SpecialPermission; import org.elasticsearch.common.Nullable; @@ -336,7 +336,7 @@ public void setDocument(int docid) { } @Override - public void setScorer(Scorer scorer) { + public void setScorer(Scorable scorer) { script.setScorer(scorer); } diff --git a/modules/lang-painless/src/test/java/org/elasticsearch/painless/ScoreTests.java b/modules/lang-painless/src/test/java/org/elasticsearch/painless/ScoreTests.java index 76bb6d14dcf61..3d19dedd3b0a3 100644 --- a/modules/lang-painless/src/test/java/org/elasticsearch/painless/ScoreTests.java +++ b/modules/lang-painless/src/test/java/org/elasticsearch/painless/ScoreTests.java @@ -19,39 +19,25 @@ package org.elasticsearch.painless; -import org.apache.lucene.search.DocIdSetIterator; -import org.apache.lucene.search.Scorer; +import org.apache.lucene.search.Scorable; -import java.io.IOException; import java.util.Collections; public class ScoreTests extends ScriptTestCase { /** Most of a dummy scorer impl that requires overriding just score(). */ - abstract class MockScorer extends Scorer { - MockScorer() { - super(null); - } + abstract class MockScorer extends Scorable { @Override public int docID() { return 0; } - @Override - public DocIdSetIterator iterator() { - throw new UnsupportedOperationException(); - } } public void testScoreWorks() { assertEquals(2.5, exec("_score", Collections.emptyMap(), Collections.emptyMap(), new MockScorer() { @Override - public float score() throws IOException { - return 2.5f; - } - - @Override - public float getMaxScore(int upTo) throws IOException { + public float score() { return 2.5f; } }, @@ -62,14 +48,9 @@ public void testScoreNotUsed() { assertEquals(3.5, exec("3.5", Collections.emptyMap(), Collections.emptyMap(), new MockScorer() { @Override - public float score() throws IOException { + public float score() { throw new AssertionError("score() should not be called"); } - - @Override - public float getMaxScore(int upTo) throws IOException { - return Float.MAX_VALUE; - } }, true)); } @@ -79,17 +60,12 @@ public void testScoreCached() { new MockScorer() { private boolean used = false; @Override - public float score() throws IOException { + public float score() { if (used == false) { return 4.5f; } throw new AssertionError("score() should not be called twice"); } - - @Override - public float getMaxScore(int upTo) throws IOException { - return 4.5f; - } }, true)); } diff --git a/modules/lang-painless/src/test/java/org/elasticsearch/painless/ScriptTestCase.java b/modules/lang-painless/src/test/java/org/elasticsearch/painless/ScriptTestCase.java index 963a433f172e8..577b120fc9024 100644 --- a/modules/lang-painless/src/test/java/org/elasticsearch/painless/ScriptTestCase.java +++ b/modules/lang-painless/src/test/java/org/elasticsearch/painless/ScriptTestCase.java @@ -20,7 +20,7 @@ package org.elasticsearch.painless; import junit.framework.AssertionFailedError; -import org.apache.lucene.search.Scorer; +import org.apache.lucene.search.Scorable; import org.elasticsearch.common.lucene.ScorerAware; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.painless.antlr.Walker; @@ -91,7 +91,7 @@ public Object exec(String script, Map vars, boolean picky) { } /** Compiles and returns the result of {@code script} with access to {@code vars} and compile-time parameters */ - public Object exec(String script, Map vars, Map compileParams, Scorer scorer, boolean picky) { + public Object exec(String script, Map vars, Map compileParams, Scorable scorer, boolean picky) { // test for ambiguity errors before running the actual script if picky is true if (picky) { ScriptClassInfo scriptClassInfo = new ScriptClassInfo(PAINLESS_LOOKUP, GenericElasticsearchScript.class); diff --git a/modules/lang-painless/src/test/java/org/elasticsearch/painless/ScriptedMetricAggContextsTests.java b/modules/lang-painless/src/test/java/org/elasticsearch/painless/ScriptedMetricAggContextsTests.java index 4820bc10cf24f..5c6fbc54667f2 100644 --- a/modules/lang-painless/src/test/java/org/elasticsearch/painless/ScriptedMetricAggContextsTests.java +++ b/modules/lang-painless/src/test/java/org/elasticsearch/painless/ScriptedMetricAggContextsTests.java @@ -19,13 +19,11 @@ package org.elasticsearch.painless; -import org.apache.lucene.search.DocIdSetIterator; -import org.apache.lucene.search.Scorer; +import org.apache.lucene.search.Scorable; import org.elasticsearch.painless.spi.Whitelist; import org.elasticsearch.script.ScriptContext; import org.elasticsearch.script.ScriptedMetricAggContexts; -import java.io.IOException; import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; @@ -66,20 +64,12 @@ public void testMapBasic() { Map params = new HashMap<>(); Map state = new HashMap<>(); - Scorer scorer = new Scorer(null) { + Scorable scorer = new Scorable() { @Override public int docID() { return 0; } @Override public float score() { return 0.5f; } - - @Override - public DocIdSetIterator iterator() { return null; } - - @Override - public float getMaxScore(int upTo) throws IOException { - return 0.5f; - } }; ScriptedMetricAggContexts.MapScript.LeafFactory leafFactory = factory.newFactory(params, state, null); diff --git a/modules/parent-join/src/main/java/org/elasticsearch/join/aggregations/ParentToChildrenAggregator.java b/modules/parent-join/src/main/java/org/elasticsearch/join/aggregations/ParentToChildrenAggregator.java index 4469c9633dd87..064d1d1e5977c 100644 --- a/modules/parent-join/src/main/java/org/elasticsearch/join/aggregations/ParentToChildrenAggregator.java +++ b/modules/parent-join/src/main/java/org/elasticsearch/join/aggregations/ParentToChildrenAggregator.java @@ -21,9 +21,9 @@ import org.apache.lucene.index.IndexReader; import org.apache.lucene.index.LeafReaderContext; import org.apache.lucene.index.SortedSetDocValues; -import org.apache.lucene.search.ConstantScoreScorer; import org.apache.lucene.search.DocIdSetIterator; import org.apache.lucene.search.Query; +import org.apache.lucene.search.Scorable; import org.apache.lucene.search.ScoreMode; import org.apache.lucene.search.Scorer; import org.apache.lucene.search.Weight; @@ -148,7 +148,17 @@ protected void doPostCollection() throws IOException { final SortedSetDocValues globalOrdinals = valuesSource.globalOrdinalsValues(ctx); // Set the scorer, since we now replay only the child docIds - sub.setScorer(new ConstantScoreScorer(null, 1f, childDocsIter)); + sub.setScorer(new Scorable() { + @Override + public float score() { + return 1f; + } + + @Override + public int docID() { + return childDocsIter.docID(); + } + }); final Bits liveDocs = ctx.reader().getLiveDocs(); for (int docId = childDocsIter diff --git a/plugins/analysis-icu/licenses/lucene-analyzers-icu-8.0.0-snapshot-4d78db26be.jar.sha1 b/plugins/analysis-icu/licenses/lucene-analyzers-icu-8.0.0-snapshot-4d78db26be.jar.sha1 deleted file mode 100644 index be2e7ec355ac5..0000000000000 --- a/plugins/analysis-icu/licenses/lucene-analyzers-icu-8.0.0-snapshot-4d78db26be.jar.sha1 +++ /dev/null @@ -1 +0,0 @@ -97a3758487272ba4d15720b0ca15b0f980310c89 \ No newline at end of file diff --git a/plugins/analysis-icu/licenses/lucene-analyzers-icu-8.0.0-snapshot-66c671ea80.jar.sha1 b/plugins/analysis-icu/licenses/lucene-analyzers-icu-8.0.0-snapshot-66c671ea80.jar.sha1 new file mode 100644 index 0000000000000..7369f427ab208 --- /dev/null +++ b/plugins/analysis-icu/licenses/lucene-analyzers-icu-8.0.0-snapshot-66c671ea80.jar.sha1 @@ -0,0 +1 @@ +f009ee188453aabae77fad55aea08bc60323bb3e \ No newline at end of file diff --git a/plugins/analysis-kuromoji/licenses/lucene-analyzers-kuromoji-8.0.0-snapshot-4d78db26be.jar.sha1 b/plugins/analysis-kuromoji/licenses/lucene-analyzers-kuromoji-8.0.0-snapshot-4d78db26be.jar.sha1 deleted file mode 100644 index a7f63df28d7e5..0000000000000 --- a/plugins/analysis-kuromoji/licenses/lucene-analyzers-kuromoji-8.0.0-snapshot-4d78db26be.jar.sha1 +++ /dev/null @@ -1 +0,0 @@ -12ed739794cd317754684308ddc5bdbdcc46cdde \ No newline at end of file diff --git a/plugins/analysis-kuromoji/licenses/lucene-analyzers-kuromoji-8.0.0-snapshot-66c671ea80.jar.sha1 b/plugins/analysis-kuromoji/licenses/lucene-analyzers-kuromoji-8.0.0-snapshot-66c671ea80.jar.sha1 new file mode 100644 index 0000000000000..16417bbebd1c2 --- /dev/null +++ b/plugins/analysis-kuromoji/licenses/lucene-analyzers-kuromoji-8.0.0-snapshot-66c671ea80.jar.sha1 @@ -0,0 +1 @@ +af3d2ae975e3560c1ea69222d6c46072857952ba \ No newline at end of file diff --git a/plugins/analysis-nori/licenses/lucene-analyzers-nori-8.0.0-snapshot-4d78db26be.jar.sha1 b/plugins/analysis-nori/licenses/lucene-analyzers-nori-8.0.0-snapshot-4d78db26be.jar.sha1 deleted file mode 100644 index 8fc57bbf7e46d..0000000000000 --- a/plugins/analysis-nori/licenses/lucene-analyzers-nori-8.0.0-snapshot-4d78db26be.jar.sha1 +++ /dev/null @@ -1 +0,0 @@ -4da6e5c17a17f0a9a99b518ea9985ea06996b63b \ No newline at end of file diff --git a/plugins/analysis-nori/licenses/lucene-analyzers-nori-8.0.0-snapshot-66c671ea80.jar.sha1 b/plugins/analysis-nori/licenses/lucene-analyzers-nori-8.0.0-snapshot-66c671ea80.jar.sha1 new file mode 100644 index 0000000000000..9c3524a6789f8 --- /dev/null +++ b/plugins/analysis-nori/licenses/lucene-analyzers-nori-8.0.0-snapshot-66c671ea80.jar.sha1 @@ -0,0 +1 @@ +f17bc5e532d9dc2786a13bd577df64023d1baae1 \ No newline at end of file diff --git a/plugins/analysis-phonetic/licenses/lucene-analyzers-phonetic-8.0.0-snapshot-4d78db26be.jar.sha1 b/plugins/analysis-phonetic/licenses/lucene-analyzers-phonetic-8.0.0-snapshot-4d78db26be.jar.sha1 deleted file mode 100644 index d94b274bf13ff..0000000000000 --- a/plugins/analysis-phonetic/licenses/lucene-analyzers-phonetic-8.0.0-snapshot-4d78db26be.jar.sha1 +++ /dev/null @@ -1 +0,0 @@ -a36b2db18a2a22966ab0bf9fced775f22dd7029d \ No newline at end of file diff --git a/plugins/analysis-phonetic/licenses/lucene-analyzers-phonetic-8.0.0-snapshot-66c671ea80.jar.sha1 b/plugins/analysis-phonetic/licenses/lucene-analyzers-phonetic-8.0.0-snapshot-66c671ea80.jar.sha1 new file mode 100644 index 0000000000000..ac81fdd07c2e4 --- /dev/null +++ b/plugins/analysis-phonetic/licenses/lucene-analyzers-phonetic-8.0.0-snapshot-66c671ea80.jar.sha1 @@ -0,0 +1 @@ +7ad89d33c1cd960c91afa05b22024137fe108567 \ No newline at end of file diff --git a/plugins/analysis-smartcn/licenses/lucene-analyzers-smartcn-8.0.0-snapshot-4d78db26be.jar.sha1 b/plugins/analysis-smartcn/licenses/lucene-analyzers-smartcn-8.0.0-snapshot-4d78db26be.jar.sha1 deleted file mode 100644 index f75d7abd6a36b..0000000000000 --- a/plugins/analysis-smartcn/licenses/lucene-analyzers-smartcn-8.0.0-snapshot-4d78db26be.jar.sha1 +++ /dev/null @@ -1 +0,0 @@ -5f1d360a47d2fd166e970d17c46b284830e64258 \ No newline at end of file diff --git a/plugins/analysis-smartcn/licenses/lucene-analyzers-smartcn-8.0.0-snapshot-66c671ea80.jar.sha1 b/plugins/analysis-smartcn/licenses/lucene-analyzers-smartcn-8.0.0-snapshot-66c671ea80.jar.sha1 new file mode 100644 index 0000000000000..f00a29e781618 --- /dev/null +++ b/plugins/analysis-smartcn/licenses/lucene-analyzers-smartcn-8.0.0-snapshot-66c671ea80.jar.sha1 @@ -0,0 +1 @@ +3f11fb254256d74e911b953994b47e7a95915954 \ No newline at end of file diff --git a/plugins/analysis-stempel/licenses/lucene-analyzers-stempel-8.0.0-snapshot-4d78db26be.jar.sha1 b/plugins/analysis-stempel/licenses/lucene-analyzers-stempel-8.0.0-snapshot-4d78db26be.jar.sha1 deleted file mode 100644 index 2e3943cf79345..0000000000000 --- a/plugins/analysis-stempel/licenses/lucene-analyzers-stempel-8.0.0-snapshot-4d78db26be.jar.sha1 +++ /dev/null @@ -1 +0,0 @@ -b07883b5e988d1d991503aa49d9b59059518825d \ No newline at end of file diff --git a/plugins/analysis-stempel/licenses/lucene-analyzers-stempel-8.0.0-snapshot-66c671ea80.jar.sha1 b/plugins/analysis-stempel/licenses/lucene-analyzers-stempel-8.0.0-snapshot-66c671ea80.jar.sha1 new file mode 100644 index 0000000000000..76fa8e90eae98 --- /dev/null +++ b/plugins/analysis-stempel/licenses/lucene-analyzers-stempel-8.0.0-snapshot-66c671ea80.jar.sha1 @@ -0,0 +1 @@ +b2348d140ef0c3e674cb81173f61c5e5f430facb \ No newline at end of file diff --git a/plugins/analysis-ukrainian/licenses/lucene-analyzers-morfologik-8.0.0-snapshot-4d78db26be.jar.sha1 b/plugins/analysis-ukrainian/licenses/lucene-analyzers-morfologik-8.0.0-snapshot-4d78db26be.jar.sha1 deleted file mode 100644 index 1d21c6e5b613c..0000000000000 --- a/plugins/analysis-ukrainian/licenses/lucene-analyzers-morfologik-8.0.0-snapshot-4d78db26be.jar.sha1 +++ /dev/null @@ -1 +0,0 @@ -1b46b3ee62932de7ba7b670820a13eb973ec5777 \ No newline at end of file diff --git a/plugins/analysis-ukrainian/licenses/lucene-analyzers-morfologik-8.0.0-snapshot-66c671ea80.jar.sha1 b/plugins/analysis-ukrainian/licenses/lucene-analyzers-morfologik-8.0.0-snapshot-66c671ea80.jar.sha1 new file mode 100644 index 0000000000000..0e2c4d34ef041 --- /dev/null +++ b/plugins/analysis-ukrainian/licenses/lucene-analyzers-morfologik-8.0.0-snapshot-66c671ea80.jar.sha1 @@ -0,0 +1 @@ +485a0c3be58a5942b4a28639f1019181ef4cd0e3 \ No newline at end of file diff --git a/server/licenses/lucene-analyzers-common-8.0.0-snapshot-4d78db26be.jar.sha1 b/server/licenses/lucene-analyzers-common-8.0.0-snapshot-4d78db26be.jar.sha1 deleted file mode 100644 index 3a02e483d6808..0000000000000 --- a/server/licenses/lucene-analyzers-common-8.0.0-snapshot-4d78db26be.jar.sha1 +++ /dev/null @@ -1 +0,0 @@ -fa8e0fbef3e3fcf49ace4a4153580070def770eb \ No newline at end of file diff --git a/server/licenses/lucene-analyzers-common-8.0.0-snapshot-66c671ea80.jar.sha1 b/server/licenses/lucene-analyzers-common-8.0.0-snapshot-66c671ea80.jar.sha1 new file mode 100644 index 0000000000000..72f7319e6af4a --- /dev/null +++ b/server/licenses/lucene-analyzers-common-8.0.0-snapshot-66c671ea80.jar.sha1 @@ -0,0 +1 @@ +a22f1c6749ca4a3fbc9b330161a8ea3301cac8de \ No newline at end of file diff --git a/server/licenses/lucene-backward-codecs-8.0.0-snapshot-4d78db26be.jar.sha1 b/server/licenses/lucene-backward-codecs-8.0.0-snapshot-4d78db26be.jar.sha1 deleted file mode 100644 index 8279b81d6cfc0..0000000000000 --- a/server/licenses/lucene-backward-codecs-8.0.0-snapshot-4d78db26be.jar.sha1 +++ /dev/null @@ -1 +0,0 @@ -3d636541581e338a1be7e3e176aac73d7ae0b323 \ No newline at end of file diff --git a/server/licenses/lucene-backward-codecs-8.0.0-snapshot-66c671ea80.jar.sha1 b/server/licenses/lucene-backward-codecs-8.0.0-snapshot-66c671ea80.jar.sha1 new file mode 100644 index 0000000000000..f4bf99b4a03a5 --- /dev/null +++ b/server/licenses/lucene-backward-codecs-8.0.0-snapshot-66c671ea80.jar.sha1 @@ -0,0 +1 @@ +41ce415b93d75662cc2e790d09120bc0234d6b1b \ No newline at end of file diff --git a/server/licenses/lucene-core-8.0.0-snapshot-4d78db26be.jar.sha1 b/server/licenses/lucene-core-8.0.0-snapshot-4d78db26be.jar.sha1 deleted file mode 100644 index 683b585bb2f61..0000000000000 --- a/server/licenses/lucene-core-8.0.0-snapshot-4d78db26be.jar.sha1 +++ /dev/null @@ -1 +0,0 @@ -126faacb28d1b8cc1ab81d702973d057892120d1 \ No newline at end of file diff --git a/server/licenses/lucene-core-8.0.0-snapshot-66c671ea80.jar.sha1 b/server/licenses/lucene-core-8.0.0-snapshot-66c671ea80.jar.sha1 new file mode 100644 index 0000000000000..50a21f5c504a2 --- /dev/null +++ b/server/licenses/lucene-core-8.0.0-snapshot-66c671ea80.jar.sha1 @@ -0,0 +1 @@ +06c1e4fa838807059d27aaf5405cfdfe7303369c \ No newline at end of file diff --git a/server/licenses/lucene-grouping-8.0.0-snapshot-4d78db26be.jar.sha1 b/server/licenses/lucene-grouping-8.0.0-snapshot-4d78db26be.jar.sha1 deleted file mode 100644 index 483f470b5e015..0000000000000 --- a/server/licenses/lucene-grouping-8.0.0-snapshot-4d78db26be.jar.sha1 +++ /dev/null @@ -1 +0,0 @@ -abd514ec02837f48b8c478287fde7cc5d6439ada \ No newline at end of file diff --git a/server/licenses/lucene-grouping-8.0.0-snapshot-66c671ea80.jar.sha1 b/server/licenses/lucene-grouping-8.0.0-snapshot-66c671ea80.jar.sha1 new file mode 100644 index 0000000000000..76bdfa1c6c4bc --- /dev/null +++ b/server/licenses/lucene-grouping-8.0.0-snapshot-66c671ea80.jar.sha1 @@ -0,0 +1 @@ +5b0a019a938deb58160647e7640b348bb99c10a8 \ No newline at end of file diff --git a/server/licenses/lucene-highlighter-8.0.0-snapshot-4d78db26be.jar.sha1 b/server/licenses/lucene-highlighter-8.0.0-snapshot-4d78db26be.jar.sha1 deleted file mode 100644 index 27dd042c06bf3..0000000000000 --- a/server/licenses/lucene-highlighter-8.0.0-snapshot-4d78db26be.jar.sha1 +++ /dev/null @@ -1 +0,0 @@ -778e87a263184b8ddcbb4ef9d244467933f32993 \ No newline at end of file diff --git a/server/licenses/lucene-highlighter-8.0.0-snapshot-66c671ea80.jar.sha1 b/server/licenses/lucene-highlighter-8.0.0-snapshot-66c671ea80.jar.sha1 new file mode 100644 index 0000000000000..017225c0e467d --- /dev/null +++ b/server/licenses/lucene-highlighter-8.0.0-snapshot-66c671ea80.jar.sha1 @@ -0,0 +1 @@ +4d813f3ba0ddd56bac728edb88ed8875e6acfd18 \ No newline at end of file diff --git a/server/licenses/lucene-join-8.0.0-snapshot-4d78db26be.jar.sha1 b/server/licenses/lucene-join-8.0.0-snapshot-4d78db26be.jar.sha1 deleted file mode 100644 index 13d2db8d210dc..0000000000000 --- a/server/licenses/lucene-join-8.0.0-snapshot-4d78db26be.jar.sha1 +++ /dev/null @@ -1 +0,0 @@ -96aff29ad966204c73f8dd98d8116f09e34b6ebd \ No newline at end of file diff --git a/server/licenses/lucene-join-8.0.0-snapshot-66c671ea80.jar.sha1 b/server/licenses/lucene-join-8.0.0-snapshot-66c671ea80.jar.sha1 new file mode 100644 index 0000000000000..29cdbbfe69f3c --- /dev/null +++ b/server/licenses/lucene-join-8.0.0-snapshot-66c671ea80.jar.sha1 @@ -0,0 +1 @@ +00c7e20b6a35ebecc875dd52bfb324967c5555d6 \ No newline at end of file diff --git a/server/licenses/lucene-memory-8.0.0-snapshot-4d78db26be.jar.sha1 b/server/licenses/lucene-memory-8.0.0-snapshot-4d78db26be.jar.sha1 deleted file mode 100644 index 6e014f20c97fd..0000000000000 --- a/server/licenses/lucene-memory-8.0.0-snapshot-4d78db26be.jar.sha1 +++ /dev/null @@ -1 +0,0 @@ -e72e2accebb1277c57dfe21bc011195eed91dbfd \ No newline at end of file diff --git a/server/licenses/lucene-memory-8.0.0-snapshot-66c671ea80.jar.sha1 b/server/licenses/lucene-memory-8.0.0-snapshot-66c671ea80.jar.sha1 new file mode 100644 index 0000000000000..49087293afa7c --- /dev/null +++ b/server/licenses/lucene-memory-8.0.0-snapshot-66c671ea80.jar.sha1 @@ -0,0 +1 @@ +e4dbff54a0befdc7d67c0f39890586c220df718e \ No newline at end of file diff --git a/server/licenses/lucene-misc-8.0.0-snapshot-4d78db26be.jar.sha1 b/server/licenses/lucene-misc-8.0.0-snapshot-4d78db26be.jar.sha1 deleted file mode 100644 index 57081e7aa10ba..0000000000000 --- a/server/licenses/lucene-misc-8.0.0-snapshot-4d78db26be.jar.sha1 +++ /dev/null @@ -1 +0,0 @@ -bf25587ebf6823781f5d7acffd7d65c46c21cb27 \ No newline at end of file diff --git a/server/licenses/lucene-misc-8.0.0-snapshot-66c671ea80.jar.sha1 b/server/licenses/lucene-misc-8.0.0-snapshot-66c671ea80.jar.sha1 new file mode 100644 index 0000000000000..3c12235dff678 --- /dev/null +++ b/server/licenses/lucene-misc-8.0.0-snapshot-66c671ea80.jar.sha1 @@ -0,0 +1 @@ +74d17f6bdf1fa4d499f02904432aa3b1024bde88 \ No newline at end of file diff --git a/server/licenses/lucene-queries-8.0.0-snapshot-4d78db26be.jar.sha1 b/server/licenses/lucene-queries-8.0.0-snapshot-4d78db26be.jar.sha1 deleted file mode 100644 index 6855364592ea5..0000000000000 --- a/server/licenses/lucene-queries-8.0.0-snapshot-4d78db26be.jar.sha1 +++ /dev/null @@ -1 +0,0 @@ -6cad42923bcb6e1c6060ae1cbab574646e8c808e \ No newline at end of file diff --git a/server/licenses/lucene-queries-8.0.0-snapshot-66c671ea80.jar.sha1 b/server/licenses/lucene-queries-8.0.0-snapshot-66c671ea80.jar.sha1 new file mode 100644 index 0000000000000..a423deb397de6 --- /dev/null +++ b/server/licenses/lucene-queries-8.0.0-snapshot-66c671ea80.jar.sha1 @@ -0,0 +1 @@ +bec78be38f777765146c35f65e247909563d6814 \ No newline at end of file diff --git a/server/licenses/lucene-queryparser-8.0.0-snapshot-4d78db26be.jar.sha1 b/server/licenses/lucene-queryparser-8.0.0-snapshot-4d78db26be.jar.sha1 deleted file mode 100644 index f9d037120a342..0000000000000 --- a/server/licenses/lucene-queryparser-8.0.0-snapshot-4d78db26be.jar.sha1 +++ /dev/null @@ -1 +0,0 @@ -e5841d7e877e51bbd2d325709353f5ab7e94b49a \ No newline at end of file diff --git a/server/licenses/lucene-queryparser-8.0.0-snapshot-66c671ea80.jar.sha1 b/server/licenses/lucene-queryparser-8.0.0-snapshot-66c671ea80.jar.sha1 new file mode 100644 index 0000000000000..79195ed1d5e1c --- /dev/null +++ b/server/licenses/lucene-queryparser-8.0.0-snapshot-66c671ea80.jar.sha1 @@ -0,0 +1 @@ +74b76f8fed44400bc2a5d938ca2611a97b4d7a7c \ No newline at end of file diff --git a/server/licenses/lucene-sandbox-8.0.0-snapshot-4d78db26be.jar.sha1 b/server/licenses/lucene-sandbox-8.0.0-snapshot-4d78db26be.jar.sha1 deleted file mode 100644 index 45c8934a8d41b..0000000000000 --- a/server/licenses/lucene-sandbox-8.0.0-snapshot-4d78db26be.jar.sha1 +++ /dev/null @@ -1 +0,0 @@ -fefe17f6ac0c7d505c5051e96d0f4916fec2bf9e \ No newline at end of file diff --git a/server/licenses/lucene-sandbox-8.0.0-snapshot-66c671ea80.jar.sha1 b/server/licenses/lucene-sandbox-8.0.0-snapshot-66c671ea80.jar.sha1 new file mode 100644 index 0000000000000..d5cd94b7fe5d6 --- /dev/null +++ b/server/licenses/lucene-sandbox-8.0.0-snapshot-66c671ea80.jar.sha1 @@ -0,0 +1 @@ +2f65fa728b3bc924db6538f4c3caf2fcd25451cf \ No newline at end of file diff --git a/server/licenses/lucene-spatial-8.0.0-snapshot-4d78db26be.jar.sha1 b/server/licenses/lucene-spatial-8.0.0-snapshot-4d78db26be.jar.sha1 deleted file mode 100644 index b02408a7683b3..0000000000000 --- a/server/licenses/lucene-spatial-8.0.0-snapshot-4d78db26be.jar.sha1 +++ /dev/null @@ -1 +0,0 @@ -22b0a9d9fb675f7c82a7a2b18f593f3278b40f11 \ No newline at end of file diff --git a/server/licenses/lucene-spatial-8.0.0-snapshot-66c671ea80.jar.sha1 b/server/licenses/lucene-spatial-8.0.0-snapshot-66c671ea80.jar.sha1 new file mode 100644 index 0000000000000..76857b72f012b --- /dev/null +++ b/server/licenses/lucene-spatial-8.0.0-snapshot-66c671ea80.jar.sha1 @@ -0,0 +1 @@ +916a91f0cab2d3684707c59e9adca7b3030b2c66 \ No newline at end of file diff --git a/server/licenses/lucene-spatial-extras-8.0.0-snapshot-4d78db26be.jar.sha1 b/server/licenses/lucene-spatial-extras-8.0.0-snapshot-4d78db26be.jar.sha1 deleted file mode 100644 index d4e8b662ce465..0000000000000 --- a/server/licenses/lucene-spatial-extras-8.0.0-snapshot-4d78db26be.jar.sha1 +++ /dev/null @@ -1 +0,0 @@ -bd6449cc67a36891f6b3201489c5ed44d795fab0 \ No newline at end of file diff --git a/server/licenses/lucene-spatial-extras-8.0.0-snapshot-66c671ea80.jar.sha1 b/server/licenses/lucene-spatial-extras-8.0.0-snapshot-66c671ea80.jar.sha1 new file mode 100644 index 0000000000000..7ab84df992bc4 --- /dev/null +++ b/server/licenses/lucene-spatial-extras-8.0.0-snapshot-66c671ea80.jar.sha1 @@ -0,0 +1 @@ +eb3e630d6013e41838fb277943ce921f256f1c61 \ No newline at end of file diff --git a/server/licenses/lucene-spatial3d-8.0.0-snapshot-4d78db26be.jar.sha1 b/server/licenses/lucene-spatial3d-8.0.0-snapshot-4d78db26be.jar.sha1 deleted file mode 100644 index 9743868e5c748..0000000000000 --- a/server/licenses/lucene-spatial3d-8.0.0-snapshot-4d78db26be.jar.sha1 +++ /dev/null @@ -1 +0,0 @@ -5e2a8b3e9e19ad61fcbd27a138cf55f2d6cbfb2d \ No newline at end of file diff --git a/server/licenses/lucene-spatial3d-8.0.0-snapshot-66c671ea80.jar.sha1 b/server/licenses/lucene-spatial3d-8.0.0-snapshot-66c671ea80.jar.sha1 new file mode 100644 index 0000000000000..d793f4c54d9d1 --- /dev/null +++ b/server/licenses/lucene-spatial3d-8.0.0-snapshot-66c671ea80.jar.sha1 @@ -0,0 +1 @@ +fa10ff14eab2f579cff2f0fa33c9c7f3b24daf12 \ No newline at end of file diff --git a/server/licenses/lucene-suggest-8.0.0-snapshot-4d78db26be.jar.sha1 b/server/licenses/lucene-suggest-8.0.0-snapshot-4d78db26be.jar.sha1 deleted file mode 100644 index 8b722955278cf..0000000000000 --- a/server/licenses/lucene-suggest-8.0.0-snapshot-4d78db26be.jar.sha1 +++ /dev/null @@ -1 +0,0 @@ -bd5931d1d5ca3f84565534182881565a44aeb72a \ No newline at end of file diff --git a/server/licenses/lucene-suggest-8.0.0-snapshot-66c671ea80.jar.sha1 b/server/licenses/lucene-suggest-8.0.0-snapshot-66c671ea80.jar.sha1 new file mode 100644 index 0000000000000..0ea0c2fb573fd --- /dev/null +++ b/server/licenses/lucene-suggest-8.0.0-snapshot-66c671ea80.jar.sha1 @@ -0,0 +1 @@ +3dd65ca6612b4f98530847b99ab348fd83055fdf \ No newline at end of file diff --git a/server/src/main/java/org/apache/lucene/search/grouping/CollapsingTopDocsCollector.java b/server/src/main/java/org/apache/lucene/search/grouping/CollapsingTopDocsCollector.java index 7f36074d1459b..e28d8990c91e3 100644 --- a/server/src/main/java/org/apache/lucene/search/grouping/CollapsingTopDocsCollector.java +++ b/server/src/main/java/org/apache/lucene/search/grouping/CollapsingTopDocsCollector.java @@ -19,9 +19,9 @@ package org.apache.lucene.search.grouping; import org.apache.lucene.search.FieldDoc; +import org.apache.lucene.search.Scorable; import org.apache.lucene.search.ScoreDoc; import org.apache.lucene.search.ScoreMode; -import org.apache.lucene.search.Scorer; import org.apache.lucene.search.Sort; import org.apache.lucene.search.SortField; import org.apache.lucene.search.TotalHits; @@ -44,7 +44,7 @@ public final class CollapsingTopDocsCollector extends FirstPassGroupingCollec protected final String collapseField; protected final Sort sort; - protected Scorer scorer; + protected Scorable scorer; private int totalHitCount; @@ -102,7 +102,7 @@ public ScoreMode scoreMode() { } @Override - public void setScorer(Scorer scorer) throws IOException { + public void setScorer(Scorable scorer) throws IOException { super.setScorer(scorer); this.scorer = scorer; } diff --git a/server/src/main/java/org/elasticsearch/action/search/MaxScoreCollector.java b/server/src/main/java/org/elasticsearch/action/search/MaxScoreCollector.java index 071cd92330496..2959802f2e3f5 100644 --- a/server/src/main/java/org/elasticsearch/action/search/MaxScoreCollector.java +++ b/server/src/main/java/org/elasticsearch/action/search/MaxScoreCollector.java @@ -19,8 +19,8 @@ package org.elasticsearch.action.search; +import org.apache.lucene.search.Scorable; import org.apache.lucene.search.ScoreMode; -import org.apache.lucene.search.Scorer; import org.apache.lucene.search.SimpleCollector; import java.io.IOException; @@ -30,12 +30,12 @@ */ public class MaxScoreCollector extends SimpleCollector { - private Scorer scorer; + private Scorable scorer; private float maxScore = Float.NEGATIVE_INFINITY; private boolean hasHits = false; @Override - public void setScorer(Scorer scorer) { + public void setScorer(Scorable scorer) { this.scorer = scorer; } diff --git a/server/src/main/java/org/elasticsearch/common/lucene/Lucene.java b/server/src/main/java/org/elasticsearch/common/lucene/Lucene.java index 47453aa8a41db..dc8628f184e43 100644 --- a/server/src/main/java/org/elasticsearch/common/lucene/Lucene.java +++ b/server/src/main/java/org/elasticsearch/common/lucene/Lucene.java @@ -745,31 +745,6 @@ public static Version parse(String toParse, Version defaultValue) { } } - /** - * Return a Scorer that throws an ElasticsearchIllegalStateException - * on all operations with the given message. - */ - public static Scorer illegalScorer(final String message) { - return new Scorer(null) { - @Override - public float score() throws IOException { - throw new IllegalStateException(message); - } - @Override - public int docID() { - throw new IllegalStateException(message); - } - @Override - public DocIdSetIterator iterator() { - throw new IllegalStateException(message); - } - @Override - public float getMaxScore(int upTo) throws IOException { - throw new IllegalStateException(message); - } - }; - } - private static final class CommitPoint extends IndexCommit { private String segmentsFileName; private final Collection files; diff --git a/server/src/main/java/org/elasticsearch/common/lucene/MinimumScoreCollector.java b/server/src/main/java/org/elasticsearch/common/lucene/MinimumScoreCollector.java index 76b59887fb946..f99d68952e557 100644 --- a/server/src/main/java/org/elasticsearch/common/lucene/MinimumScoreCollector.java +++ b/server/src/main/java/org/elasticsearch/common/lucene/MinimumScoreCollector.java @@ -22,9 +22,9 @@ import org.apache.lucene.index.LeafReaderContext; import org.apache.lucene.search.Collector; import org.apache.lucene.search.LeafCollector; +import org.apache.lucene.search.Scorable; import org.apache.lucene.search.ScoreCachingWrappingScorer; import org.apache.lucene.search.ScoreMode; -import org.apache.lucene.search.Scorer; import org.apache.lucene.search.SimpleCollector; import java.io.IOException; @@ -34,7 +34,7 @@ public class MinimumScoreCollector extends SimpleCollector { private final Collector collector; private final float minimumScore; - private Scorer scorer; + private Scorable scorer; private LeafCollector leafCollector; public MinimumScoreCollector(Collector collector, float minimumScore) { @@ -43,7 +43,7 @@ public MinimumScoreCollector(Collector collector, float minimumScore) { } @Override - public void setScorer(Scorer scorer) throws IOException { + public void setScorer(Scorable scorer) throws IOException { if (!(scorer instanceof ScoreCachingWrappingScorer)) { scorer = new ScoreCachingWrappingScorer(scorer); } diff --git a/server/src/main/java/org/elasticsearch/common/lucene/ScorerAware.java b/server/src/main/java/org/elasticsearch/common/lucene/ScorerAware.java index df17f8d7757b3..13a2a23ec56a6 100644 --- a/server/src/main/java/org/elasticsearch/common/lucene/ScorerAware.java +++ b/server/src/main/java/org/elasticsearch/common/lucene/ScorerAware.java @@ -18,10 +18,10 @@ */ package org.elasticsearch.common.lucene; -import org.apache.lucene.search.Scorer; +import org.apache.lucene.search.Scorable; public interface ScorerAware { - void setScorer(Scorer scorer); + void setScorer(Scorable scorer); } diff --git a/server/src/main/java/org/elasticsearch/common/lucene/search/function/MinScoreScorer.java b/server/src/main/java/org/elasticsearch/common/lucene/search/function/MinScoreScorer.java index 5296926e9869d..204f69f1e0af0 100644 --- a/server/src/main/java/org/elasticsearch/common/lucene/search/function/MinScoreScorer.java +++ b/server/src/main/java/org/elasticsearch/common/lucene/search/function/MinScoreScorer.java @@ -19,14 +19,13 @@ package org.elasticsearch.common.lucene.search.function; -import java.io.IOException; - import org.apache.lucene.search.DocIdSetIterator; -import org.apache.lucene.search.ScoreCachingWrappingScorer; import org.apache.lucene.search.Scorer; import org.apache.lucene.search.TwoPhaseIterator; import org.apache.lucene.search.Weight; +import java.io.IOException; + /** A {@link Scorer} that filters out documents that have a score that is * lower than a configured constant. */ final class MinScoreScorer extends Scorer { @@ -34,13 +33,10 @@ final class MinScoreScorer extends Scorer { private final Scorer in; private final float minScore; + private float curScore; + MinScoreScorer(Weight weight, Scorer scorer, float minScore) { super(weight); - if (scorer instanceof ScoreCachingWrappingScorer == false) { - // when minScore is set, scores might be requested twice: once - // to verify the match, and once by the collector - scorer = new ScoreCachingWrappingScorer(scorer); - } this.in = scorer; this.minScore = minScore; } @@ -55,8 +51,8 @@ public int docID() { } @Override - public float score() throws IOException { - return in.score(); + public float score() { + return curScore; } @Override @@ -87,7 +83,8 @@ public boolean matches() throws IOException { if (inTwoPhase != null && inTwoPhase.matches() == false) { return false; } - return in.score() >= minScore; + curScore = in.score(); + return curScore >= minScore; } @Override diff --git a/server/src/main/java/org/elasticsearch/common/lucene/search/function/ScriptScoreFunction.java b/server/src/main/java/org/elasticsearch/common/lucene/search/function/ScriptScoreFunction.java index bf1ea637a9671..5edc1659f54f7 100644 --- a/server/src/main/java/org/elasticsearch/common/lucene/search/function/ScriptScoreFunction.java +++ b/server/src/main/java/org/elasticsearch/common/lucene/search/function/ScriptScoreFunction.java @@ -20,9 +20,8 @@ package org.elasticsearch.common.lucene.search.function; import org.apache.lucene.index.LeafReaderContext; -import org.apache.lucene.search.DocIdSetIterator; import org.apache.lucene.search.Explanation; -import org.apache.lucene.search.Scorer; +import org.apache.lucene.search.Scorable; import org.elasticsearch.script.ExplainableSearchScript; import org.elasticsearch.script.ScoreScript; import org.elasticsearch.script.Script; @@ -32,33 +31,19 @@ public class ScriptScoreFunction extends ScoreFunction { - static final class CannedScorer extends Scorer { + static final class CannedScorer extends Scorable { protected int docid; protected float score; - CannedScorer() { - super(null); - } - @Override public int docID() { return docid; } @Override - public float score() throws IOException { + public float score() { return score; } - - @Override - public DocIdSetIterator iterator() { - throw new UnsupportedOperationException(); - } - - @Override - public float getMaxScore(int upTo) throws IOException { - throw new UnsupportedOperationException(); - } } private final Script sScript; diff --git a/server/src/main/java/org/elasticsearch/index/fielddata/fieldcomparator/BytesRefFieldComparatorSource.java b/server/src/main/java/org/elasticsearch/index/fielddata/fieldcomparator/BytesRefFieldComparatorSource.java index eaa16e9f07db8..8e0a31859a132 100644 --- a/server/src/main/java/org/elasticsearch/index/fielddata/fieldcomparator/BytesRefFieldComparatorSource.java +++ b/server/src/main/java/org/elasticsearch/index/fielddata/fieldcomparator/BytesRefFieldComparatorSource.java @@ -25,7 +25,7 @@ import org.apache.lucene.index.SortedSetDocValues; import org.apache.lucene.search.DocIdSetIterator; import org.apache.lucene.search.FieldComparator; -import org.apache.lucene.search.Scorer; +import org.apache.lucene.search.Scorable; import org.apache.lucene.search.SortField; import org.apache.lucene.util.BitSet; import org.apache.lucene.util.BytesRef; @@ -71,7 +71,7 @@ protected SortedBinaryDocValues getValues(LeafReaderContext context) throws IOEx return indexFieldData.load(context).getBytesValues(); } - protected void setScorer(Scorer scorer) {} + protected void setScorer(Scorable scorer) {} @Override public FieldComparator newComparator(String fieldname, int numHits, int sortPos, boolean reversed) { @@ -101,7 +101,7 @@ protected SortedDocValues getSortedDocValues(LeafReaderContext context, String f } @Override - public void setScorer(Scorer scorer) { + public void setScorer(Scorable scorer) { BytesRefFieldComparatorSource.this.setScorer(scorer); } @@ -125,7 +125,7 @@ protected BinaryDocValues getBinaryDocValues(LeafReaderContext context, String f } @Override - public void setScorer(Scorer scorer) { + public void setScorer(Scorable scorer) { BytesRefFieldComparatorSource.this.setScorer(scorer); } diff --git a/server/src/main/java/org/elasticsearch/index/fielddata/fieldcomparator/DoubleValuesComparatorSource.java b/server/src/main/java/org/elasticsearch/index/fielddata/fieldcomparator/DoubleValuesComparatorSource.java index 43bc19a12a384..1ae3fb692ec61 100644 --- a/server/src/main/java/org/elasticsearch/index/fielddata/fieldcomparator/DoubleValuesComparatorSource.java +++ b/server/src/main/java/org/elasticsearch/index/fielddata/fieldcomparator/DoubleValuesComparatorSource.java @@ -23,7 +23,7 @@ import org.apache.lucene.index.NumericDocValues; import org.apache.lucene.search.DocIdSetIterator; import org.apache.lucene.search.FieldComparator; -import org.apache.lucene.search.Scorer; +import org.apache.lucene.search.Scorable; import org.apache.lucene.search.SortField; import org.apache.lucene.util.BitSet; import org.elasticsearch.common.Nullable; @@ -57,7 +57,7 @@ protected SortedNumericDoubleValues getValues(LeafReaderContext context) throws return indexFieldData.load(context).getDoubleValues(); } - protected void setScorer(Scorer scorer) {} + protected void setScorer(Scorable scorer) {} @Override public FieldComparator newComparator(String fieldname, int numHits, int sortPos, boolean reversed) { @@ -81,7 +81,7 @@ protected NumericDocValues getNumericDocValues(LeafReaderContext context, String return selectedValues.getRawDoubleValues(); } @Override - public void setScorer(Scorer scorer) { + public void setScorer(Scorable scorer) { DoubleValuesComparatorSource.this.setScorer(scorer); } }; diff --git a/server/src/main/java/org/elasticsearch/script/ScoreAccessor.java b/server/src/main/java/org/elasticsearch/script/ScoreAccessor.java index e8c433347b916..b3cdecb3e0485 100644 --- a/server/src/main/java/org/elasticsearch/script/ScoreAccessor.java +++ b/server/src/main/java/org/elasticsearch/script/ScoreAccessor.java @@ -19,7 +19,7 @@ package org.elasticsearch.script; -import org.apache.lucene.search.Scorer; +import org.apache.lucene.search.Scorable; import org.elasticsearch.search.lookup.DocLookup; import java.io.IOException; @@ -32,9 +32,9 @@ */ public final class ScoreAccessor extends Number implements Comparable { - Scorer scorer; + Scorable scorer; - public ScoreAccessor(Scorer scorer) { + public ScoreAccessor(Scorable scorer) { this.scorer = scorer; } diff --git a/server/src/main/java/org/elasticsearch/script/ScoreScript.java b/server/src/main/java/org/elasticsearch/script/ScoreScript.java index d9e56d5573cae..11b135e9a65af 100644 --- a/server/src/main/java/org/elasticsearch/script/ScoreScript.java +++ b/server/src/main/java/org/elasticsearch/script/ScoreScript.java @@ -19,7 +19,7 @@ package org.elasticsearch.script; import org.apache.lucene.index.LeafReaderContext; -import org.apache.lucene.search.Scorer; +import org.apache.lucene.search.Scorable; import org.elasticsearch.index.fielddata.ScriptDocValues; import org.elasticsearch.search.lookup.LeafSearchLookup; import org.elasticsearch.search.lookup.SearchLookup; @@ -33,40 +33,40 @@ * A script used for adjusting the score on a per document basis. */ public abstract class ScoreScript { - + public static final String[] PARAMETERS = new String[]{}; - + /** The generic runtime parameters for the script. */ private final Map params; - + /** A leaf lookup for the bound segment this script will operate on. */ private final LeafSearchLookup leafLookup; - + private DoubleSupplier scoreSupplier = () -> 0.0; - + public ScoreScript(Map params, SearchLookup lookup, LeafReaderContext leafContext) { this.params = params; this.leafLookup = lookup.getLeafSearchLookup(leafContext); } - + public abstract double execute(); - + /** Return the parameters for this script. */ public Map getParams() { return params; } - + /** The doc lookup for the Lucene segment this script was created for. */ public final Map> getDoc() { return leafLookup.doc(); } - + /** Set the current document to run the script on next. */ public void setDocument(int docid) { leafLookup.setDocument(docid); } - - public void setScorer(Scorer scorer) { + + public void setScorer(Scorable scorer) { this.scoreSupplier = () -> { try { return scorer.score(); @@ -75,28 +75,28 @@ public void setScorer(Scorer scorer) { } }; } - + public double get_score() { return scoreSupplier.getAsDouble(); } - + /** A factory to construct {@link ScoreScript} instances. */ public interface LeafFactory { - + /** * Return {@code true} if the script needs {@code _score} calculated, or {@code false} otherwise. */ boolean needs_score(); - + ScoreScript newInstance(LeafReaderContext ctx) throws IOException; } - + /** A factory to construct stateful {@link ScoreScript} factories for a specific index. */ public interface Factory { - + ScoreScript.LeafFactory newFactory(Map params, SearchLookup lookup); - + } - + public static final ScriptContext CONTEXT = new ScriptContext<>("score", ScoreScript.Factory.class); } diff --git a/server/src/main/java/org/elasticsearch/script/ScriptedMetricAggContexts.java b/server/src/main/java/org/elasticsearch/script/ScriptedMetricAggContexts.java index 9f6ea999a9306..e72d597a6afb4 100644 --- a/server/src/main/java/org/elasticsearch/script/ScriptedMetricAggContexts.java +++ b/server/src/main/java/org/elasticsearch/script/ScriptedMetricAggContexts.java @@ -20,7 +20,7 @@ package org.elasticsearch.script; import org.apache.lucene.index.LeafReaderContext; -import org.apache.lucene.search.Scorer; +import org.apache.lucene.search.Scorable; import org.elasticsearch.ElasticsearchException; import org.elasticsearch.index.fielddata.ScriptDocValues; import org.elasticsearch.search.lookup.LeafSearchLookup; @@ -66,7 +66,7 @@ public interface Factory { public abstract static class MapScript extends ParamsAndStateBase { private final LeafSearchLookup leafLookup; - private Scorer scorer; + private Scorable scorer; public MapScript(Map params, Map state, SearchLookup lookup, LeafReaderContext leafContext) { super(params, state); @@ -86,7 +86,7 @@ public void setDocument(int docId) { } } - public void setScorer(Scorer scorer) { + public void setScorer(Scorable scorer) { this.scorer = scorer; } diff --git a/server/src/main/java/org/elasticsearch/script/SearchScript.java b/server/src/main/java/org/elasticsearch/script/SearchScript.java index 7bef78f9930c4..fb5f950d61d7e 100644 --- a/server/src/main/java/org/elasticsearch/script/SearchScript.java +++ b/server/src/main/java/org/elasticsearch/script/SearchScript.java @@ -19,7 +19,7 @@ package org.elasticsearch.script; import org.apache.lucene.index.LeafReaderContext; -import org.apache.lucene.search.Scorer; +import org.apache.lucene.search.Scorable; import org.elasticsearch.ElasticsearchException; import org.elasticsearch.common.lucene.ScorerAware; import org.elasticsearch.search.lookup.LeafDocLookup; @@ -50,7 +50,7 @@ public abstract class SearchScript implements ScorerAware, ExecutableScript { private final LeafSearchLookup leafLookup; /** A scorer that will return the score for the current document when the script is run. */ - private Scorer scorer; + private Scorable scorer; public SearchScript(Map params, SearchLookup lookup, LeafReaderContext leafContext) { this.params = params; @@ -83,7 +83,7 @@ public void setDocument(int docid) { } @Override - public void setScorer(Scorer scorer) { + public void setScorer(Scorable scorer) { this.scorer = scorer; } diff --git a/server/src/main/java/org/elasticsearch/search/aggregations/AggregatorFactory.java b/server/src/main/java/org/elasticsearch/search/aggregations/AggregatorFactory.java index 59b63520a1bd3..d6e7aca46a63b 100644 --- a/server/src/main/java/org/elasticsearch/search/aggregations/AggregatorFactory.java +++ b/server/src/main/java/org/elasticsearch/search/aggregations/AggregatorFactory.java @@ -20,8 +20,8 @@ package org.elasticsearch.search.aggregations; import org.apache.lucene.index.LeafReaderContext; +import org.apache.lucene.search.Scorable; import org.apache.lucene.search.ScoreMode; -import org.apache.lucene.search.Scorer; import org.elasticsearch.common.lease.Releasables; import org.elasticsearch.common.util.BigArrays; import org.elasticsearch.common.util.ObjectArray; @@ -110,10 +110,10 @@ public LeafBucketCollector getLeafCollector(final LeafReaderContext ctx) { collectors.set(i, null); } return new LeafBucketCollector() { - Scorer scorer; + Scorable scorer; @Override - public void setScorer(Scorer scorer) throws IOException { + public void setScorer(Scorable scorer) throws IOException { this.scorer = scorer; } diff --git a/server/src/main/java/org/elasticsearch/search/aggregations/LeafBucketCollector.java b/server/src/main/java/org/elasticsearch/search/aggregations/LeafBucketCollector.java index f5b7f15bb9403..367e1cce0608d 100644 --- a/server/src/main/java/org/elasticsearch/search/aggregations/LeafBucketCollector.java +++ b/server/src/main/java/org/elasticsearch/search/aggregations/LeafBucketCollector.java @@ -20,7 +20,7 @@ package org.elasticsearch.search.aggregations; import org.apache.lucene.search.LeafCollector; -import org.apache.lucene.search.Scorer; +import org.apache.lucene.search.Scorable; import java.io.IOException; import java.util.stream.Stream; @@ -33,7 +33,7 @@ public abstract class LeafBucketCollector implements LeafCollector { public static final LeafBucketCollector NO_OP_COLLECTOR = new LeafBucketCollector() { @Override - public void setScorer(Scorer arg0) throws IOException { + public void setScorer(Scorable arg0) throws IOException { // no-op } @Override @@ -55,7 +55,7 @@ public static LeafBucketCollector wrap(Iterable collectors) return new LeafBucketCollector() { @Override - public void setScorer(Scorer s) throws IOException { + public void setScorer(Scorable s) throws IOException { for (LeafBucketCollector c : colls) { c.setScorer(s); } @@ -83,7 +83,7 @@ public final void collect(int doc) throws IOException { } @Override - public void setScorer(Scorer scorer) throws IOException { + public void setScorer(Scorable scorer) throws IOException { // no-op by default } } diff --git a/server/src/main/java/org/elasticsearch/search/aggregations/LeafBucketCollectorBase.java b/server/src/main/java/org/elasticsearch/search/aggregations/LeafBucketCollectorBase.java index 45e7db08e2d27..529483107b192 100644 --- a/server/src/main/java/org/elasticsearch/search/aggregations/LeafBucketCollectorBase.java +++ b/server/src/main/java/org/elasticsearch/search/aggregations/LeafBucketCollectorBase.java @@ -19,7 +19,7 @@ package org.elasticsearch.search.aggregations; -import org.apache.lucene.search.Scorer; +import org.apache.lucene.search.Scorable; import org.elasticsearch.common.lucene.ScorerAware; import java.io.IOException; @@ -48,7 +48,7 @@ public LeafBucketCollectorBase(LeafBucketCollector sub, Object values) { } @Override - public void setScorer(Scorer s) throws IOException { + public void setScorer(Scorable s) throws IOException { sub.setScorer(s); if (values != null) { values.setScorer(s); diff --git a/server/src/main/java/org/elasticsearch/search/aggregations/MultiBucketCollector.java b/server/src/main/java/org/elasticsearch/search/aggregations/MultiBucketCollector.java index 624c8d5409a56..552ad8c024ddc 100644 --- a/server/src/main/java/org/elasticsearch/search/aggregations/MultiBucketCollector.java +++ b/server/src/main/java/org/elasticsearch/search/aggregations/MultiBucketCollector.java @@ -24,9 +24,9 @@ import org.apache.lucene.search.Collector; import org.apache.lucene.search.LeafCollector; import org.apache.lucene.search.MultiCollector; +import org.apache.lucene.search.Scorable; import org.apache.lucene.search.ScoreCachingWrappingScorer; import org.apache.lucene.search.ScoreMode; -import org.apache.lucene.search.Scorer; import java.io.IOException; import java.util.ArrayList; @@ -174,7 +174,7 @@ private MultiLeafBucketCollector(List collectors, boolean c } @Override - public void setScorer(Scorer scorer) throws IOException { + public void setScorer(Scorable scorer) throws IOException { if (cacheScores) { scorer = new ScoreCachingWrappingScorer(scorer); } diff --git a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/sampler/BestDocsDeferringCollector.java b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/sampler/BestDocsDeferringCollector.java index 4e63d693d1875..9ef72ad17d8fb 100644 --- a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/sampler/BestDocsDeferringCollector.java +++ b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/sampler/BestDocsDeferringCollector.java @@ -19,11 +19,10 @@ package org.elasticsearch.search.aggregations.bucket.sampler; import org.apache.lucene.index.LeafReaderContext; -import org.apache.lucene.search.DocIdSetIterator; import org.apache.lucene.search.LeafCollector; +import org.apache.lucene.search.Scorable; import org.apache.lucene.search.ScoreDoc; import org.apache.lucene.search.ScoreMode; -import org.apache.lucene.search.Scorer; import org.apache.lucene.search.TopDocs; import org.apache.lucene.search.TopDocsCollector; import org.apache.lucene.search.TopScoreDocCollector; @@ -89,7 +88,7 @@ public LeafBucketCollector getLeafCollector(LeafReaderContext ctx) throws IOExce // Deferring collector return new LeafBucketCollector() { @Override - public void setScorer(Scorer scorer) throws IOException { + public void setScorer(Scorable scorer) throws IOException { perSegCollector.setScorer(scorer); } @@ -156,7 +155,7 @@ class PerParentBucketSamples { private long parentBucket; private int matchedDocs; - PerParentBucketSamples(long parentBucket, Scorer scorer, LeafReaderContext readerContext) { + PerParentBucketSamples(long parentBucket, Scorable scorer, LeafReaderContext readerContext) { try { this.parentBucket = parentBucket; tdc = createTopDocsCollector(shardSize); @@ -185,7 +184,7 @@ public void collect(int doc) throws IOException { currentLeafCollector.collect(doc); } - public void setScorer(Scorer scorer) throws IOException { + public void setScorer(Scorable scorer) throws IOException { currentLeafCollector.setScorer(scorer); } @@ -198,19 +197,18 @@ public int getDocCount() { } } - class PerSegmentCollects extends Scorer { + class PerSegmentCollects extends Scorable { private LeafReaderContext readerContext; int maxDocId = Integer.MIN_VALUE; private float currentScore; private int currentDocId = -1; - private Scorer currentScorer; + private Scorable currentScorer; PerSegmentCollects(LeafReaderContext readerContext) throws IOException { // The publisher behaviour for Reader/Scorer listeners triggers a // call to this constructor with a null scorer so we can't call // scorer.getWeight() and pass the Weight to our base class. // However, passing null seems to have no adverse effects here... - super(null); this.readerContext = readerContext; for (int i = 0; i < perBucketSamples.size(); i++) { PerParentBucketSamples perBucketSample = perBucketSamples.get(i); @@ -221,7 +219,7 @@ class PerSegmentCollects extends Scorer { } } - public void setScorer(Scorer scorer) throws IOException { + public void setScorer(Scorable scorer) throws IOException { this.currentScorer = scorer; for (int i = 0; i < perBucketSamples.size(); i++) { PerParentBucketSamples perBucketSample = perBucketSamples.get(i); @@ -266,11 +264,6 @@ public int docID() { return currentDocId; } - @Override - public DocIdSetIterator iterator() { - throw new ElasticsearchException("This caching scorer implementation only implements score() and docID()"); - } - public void collect(int docId, long parentBucket) throws IOException { perBucketSamples = bigArrays.grow(perBucketSamples, parentBucket + 1); PerParentBucketSamples sampler = perBucketSamples.get((int) parentBucket); @@ -282,10 +275,6 @@ public void collect(int docId, long parentBucket) throws IOException { maxDocId = Math.max(maxDocId, docId); } - @Override - public float getMaxScore(int upTo) throws IOException { - return Float.MAX_VALUE; - } } public int getDocCount(long parentBucket) { diff --git a/server/src/main/java/org/elasticsearch/search/aggregations/metrics/ScriptedMetricAggregator.java b/server/src/main/java/org/elasticsearch/search/aggregations/metrics/ScriptedMetricAggregator.java index a0c287f6eac51..345b21d03887e 100644 --- a/server/src/main/java/org/elasticsearch/search/aggregations/metrics/ScriptedMetricAggregator.java +++ b/server/src/main/java/org/elasticsearch/search/aggregations/metrics/ScriptedMetricAggregator.java @@ -20,11 +20,11 @@ package org.elasticsearch.search.aggregations.metrics; import org.apache.lucene.index.LeafReaderContext; +import org.apache.lucene.search.Scorable; import org.apache.lucene.search.ScoreMode; -import org.apache.lucene.search.Scorer; import org.elasticsearch.common.util.CollectionUtils; -import org.elasticsearch.script.ScriptedMetricAggContexts; import org.elasticsearch.script.Script; +import org.elasticsearch.script.ScriptedMetricAggContexts; import org.elasticsearch.search.aggregations.Aggregator; import org.elasticsearch.search.aggregations.InternalAggregation; import org.elasticsearch.search.aggregations.LeafBucketCollector; @@ -70,7 +70,7 @@ public LeafBucketCollector getLeafCollector(LeafReaderContext ctx, final ScriptedMetricAggContexts.MapScript leafMapScript = mapScript.newInstance(ctx); return new LeafBucketCollectorBase(sub, leafMapScript) { @Override - public void setScorer(Scorer scorer) throws IOException { + public void setScorer(Scorable scorer) throws IOException { leafMapScript.setScorer(scorer); } diff --git a/server/src/main/java/org/elasticsearch/search/aggregations/metrics/TopHitsAggregator.java b/server/src/main/java/org/elasticsearch/search/aggregations/metrics/TopHitsAggregator.java index ddd62b82500ac..c017eb4a5e3bc 100644 --- a/server/src/main/java/org/elasticsearch/search/aggregations/metrics/TopHitsAggregator.java +++ b/server/src/main/java/org/elasticsearch/search/aggregations/metrics/TopHitsAggregator.java @@ -21,15 +21,14 @@ import com.carrotsearch.hppc.LongObjectHashMap; import com.carrotsearch.hppc.cursors.ObjectCursor; - import org.apache.lucene.index.LeafReaderContext; import org.apache.lucene.search.Collector; import org.apache.lucene.search.FieldDoc; import org.apache.lucene.search.LeafCollector; import org.apache.lucene.search.MultiCollector; +import org.apache.lucene.search.Scorable; import org.apache.lucene.search.ScoreDoc; import org.apache.lucene.search.ScoreMode; -import org.apache.lucene.search.Scorer; import org.apache.lucene.search.TopDocs; import org.apache.lucene.search.TopDocsCollector; import org.apache.lucene.search.TopFieldCollector; @@ -106,10 +105,10 @@ public LeafBucketCollector getLeafCollector(LeafReaderContext ctx, LeafBucketCol final LongObjectHashMap leafCollectors = new LongObjectHashMap<>(1); return new LeafBucketCollectorBase(sub, null) { - Scorer scorer; + Scorable scorer; @Override - public void setScorer(Scorer scorer) throws IOException { + public void setScorer(Scorable scorer) throws IOException { this.scorer = scorer; super.setScorer(scorer); for (ObjectCursor cursor : leafCollectors.values()) { diff --git a/server/src/main/java/org/elasticsearch/search/aggregations/support/ValuesSource.java b/server/src/main/java/org/elasticsearch/search/aggregations/support/ValuesSource.java index 25e3d38af5baa..4e6760f44fe90 100644 --- a/server/src/main/java/org/elasticsearch/search/aggregations/support/ValuesSource.java +++ b/server/src/main/java/org/elasticsearch/search/aggregations/support/ValuesSource.java @@ -26,7 +26,7 @@ import org.apache.lucene.index.SortedNumericDocValues; import org.apache.lucene.index.SortedSetDocValues; import org.apache.lucene.search.IndexSearcher; -import org.apache.lucene.search.Scorer; +import org.apache.lucene.search.Scorable; import org.apache.lucene.util.BytesRef; import org.elasticsearch.common.lucene.ScorerAware; import org.elasticsearch.common.util.CollectionUtils; @@ -295,7 +295,7 @@ static class LongValues extends AbstractSortingNumericDocValues implements Score } @Override - public void setScorer(Scorer scorer) { + public void setScorer(Scorable scorer) { script.setScorer(scorer); } @@ -326,7 +326,7 @@ static class DoubleValues extends SortingNumericDoubleValues implements ScorerAw } @Override - public void setScorer(Scorer scorer) { + public void setScorer(Scorable scorer) { script.setScorer(scorer); } @@ -445,7 +445,7 @@ static class BytesValues extends SortingBinaryDocValues implements ScorerAware { } @Override - public void setScorer(Scorer scorer) { + public void setScorer(Scorable scorer) { script.setScorer(scorer); } diff --git a/server/src/main/java/org/elasticsearch/search/aggregations/support/values/ScriptBytesValues.java b/server/src/main/java/org/elasticsearch/search/aggregations/support/values/ScriptBytesValues.java index 5ec1858487e09..144e08ce6f275 100644 --- a/server/src/main/java/org/elasticsearch/search/aggregations/support/values/ScriptBytesValues.java +++ b/server/src/main/java/org/elasticsearch/search/aggregations/support/values/ScriptBytesValues.java @@ -18,7 +18,7 @@ */ package org.elasticsearch.search.aggregations.support.values; -import org.apache.lucene.search.Scorer; +import org.apache.lucene.search.Scorable; import org.elasticsearch.common.lucene.ScorerAware; import org.elasticsearch.common.util.CollectionUtils; import org.elasticsearch.index.fielddata.SortedBinaryDocValues; @@ -85,7 +85,7 @@ public boolean advanceExact(int doc) throws IOException { } @Override - public void setScorer(Scorer scorer) { + public void setScorer(Scorable scorer) { script.setScorer(scorer); } } diff --git a/server/src/main/java/org/elasticsearch/search/aggregations/support/values/ScriptDoubleValues.java b/server/src/main/java/org/elasticsearch/search/aggregations/support/values/ScriptDoubleValues.java index 1227efb5ea0af..4bb531c0d40d7 100644 --- a/server/src/main/java/org/elasticsearch/search/aggregations/support/values/ScriptDoubleValues.java +++ b/server/src/main/java/org/elasticsearch/search/aggregations/support/values/ScriptDoubleValues.java @@ -18,7 +18,7 @@ */ package org.elasticsearch.search.aggregations.support.values; -import org.apache.lucene.search.Scorer; +import org.apache.lucene.search.Scorable; import org.elasticsearch.common.lucene.ScorerAware; import org.elasticsearch.index.fielddata.SortingNumericDoubleValues; import org.elasticsearch.script.SearchScript; @@ -107,7 +107,7 @@ private static double toDoubleValue(Object o) { } @Override - public void setScorer(Scorer scorer) { + public void setScorer(Scorable scorer) { script.setScorer(scorer); } } diff --git a/server/src/main/java/org/elasticsearch/search/aggregations/support/values/ScriptLongValues.java b/server/src/main/java/org/elasticsearch/search/aggregations/support/values/ScriptLongValues.java index cdc448bd04130..c57afa1960d97 100644 --- a/server/src/main/java/org/elasticsearch/search/aggregations/support/values/ScriptLongValues.java +++ b/server/src/main/java/org/elasticsearch/search/aggregations/support/values/ScriptLongValues.java @@ -18,7 +18,7 @@ */ package org.elasticsearch.search.aggregations.support.values; -import org.apache.lucene.search.Scorer; +import org.apache.lucene.search.Scorable; import org.apache.lucene.util.LongValues; import org.elasticsearch.common.lucene.ScorerAware; import org.elasticsearch.index.fielddata.AbstractSortingNumericDocValues; @@ -106,7 +106,7 @@ private static long toLongValue(Object o) { } @Override - public void setScorer(Scorer scorer) { + public void setScorer(Scorable scorer) { script.setScorer(scorer); } } diff --git a/server/src/main/java/org/elasticsearch/search/profile/aggregation/ProfilingLeafBucketCollector.java b/server/src/main/java/org/elasticsearch/search/profile/aggregation/ProfilingLeafBucketCollector.java index 4db67967dcb2b..cc84b1cfb668f 100644 --- a/server/src/main/java/org/elasticsearch/search/profile/aggregation/ProfilingLeafBucketCollector.java +++ b/server/src/main/java/org/elasticsearch/search/profile/aggregation/ProfilingLeafBucketCollector.java @@ -19,7 +19,7 @@ package org.elasticsearch.search.profile.aggregation; -import org.apache.lucene.search.Scorer; +import org.apache.lucene.search.Scorable; import org.elasticsearch.search.aggregations.LeafBucketCollector; import org.elasticsearch.search.profile.Timer; @@ -46,7 +46,7 @@ public void collect(int doc, long bucket) throws IOException { } @Override - public void setScorer(Scorer scorer) throws IOException { + public void setScorer(Scorable scorer) throws IOException { delegate.setScorer(scorer); } diff --git a/server/src/main/java/org/elasticsearch/search/profile/query/ProfileCollector.java b/server/src/main/java/org/elasticsearch/search/profile/query/ProfileCollector.java index 940e3902954b5..b900cb04f79dd 100644 --- a/server/src/main/java/org/elasticsearch/search/profile/query/ProfileCollector.java +++ b/server/src/main/java/org/elasticsearch/search/profile/query/ProfileCollector.java @@ -24,8 +24,8 @@ import org.apache.lucene.search.FilterCollector; import org.apache.lucene.search.FilterLeafCollector; import org.apache.lucene.search.LeafCollector; +import org.apache.lucene.search.Scorable; import org.apache.lucene.search.ScoreMode; -import org.apache.lucene.search.Scorer; import java.io.IOException; @@ -76,7 +76,7 @@ public void collect(int doc) throws IOException { } @Override - public void setScorer(Scorer scorer) throws IOException { + public void setScorer(Scorable scorer) throws IOException { final long start = System.nanoTime(); try { super.setScorer(scorer); diff --git a/server/src/main/java/org/elasticsearch/search/profile/query/ProfileScorer.java b/server/src/main/java/org/elasticsearch/search/profile/query/ProfileScorer.java index 8913f484847e6..7899750461e52 100644 --- a/server/src/main/java/org/elasticsearch/search/profile/query/ProfileScorer.java +++ b/server/src/main/java/org/elasticsearch/search/profile/query/ProfileScorer.java @@ -71,7 +71,7 @@ public Weight getWeight() { } @Override - public Collection getChildren() throws IOException { + public Collection getChildren() throws IOException { return scorer.getChildren(); } diff --git a/server/src/main/java/org/elasticsearch/search/sort/ScriptSortBuilder.java b/server/src/main/java/org/elasticsearch/search/sort/ScriptSortBuilder.java index 4759027ee51b0..1b71c51d4162b 100644 --- a/server/src/main/java/org/elasticsearch/search/sort/ScriptSortBuilder.java +++ b/server/src/main/java/org/elasticsearch/search/sort/ScriptSortBuilder.java @@ -21,7 +21,7 @@ import org.apache.lucene.index.BinaryDocValues; import org.apache.lucene.index.LeafReaderContext; -import org.apache.lucene.search.Scorer; +import org.apache.lucene.search.Scorable; import org.apache.lucene.search.SortField; import org.apache.lucene.util.BytesRef; import org.apache.lucene.util.BytesRefBuilder; @@ -351,7 +351,7 @@ public BytesRef binaryValue() { return FieldData.singleton(values); } @Override - protected void setScorer(Scorer scorer) { + protected void setScorer(Scorable scorer) { leafScript.setScorer(scorer); } }; @@ -376,7 +376,7 @@ public double doubleValue() { return FieldData.singleton(values); } @Override - protected void setScorer(Scorer scorer) { + protected void setScorer(Scorable scorer) { leafScript.setScorer(scorer); } }; diff --git a/server/src/test/java/org/elasticsearch/common/lucene/search/function/MinScoreScorerTests.java b/server/src/test/java/org/elasticsearch/common/lucene/search/function/MinScoreScorerTests.java index d60458cf82642..e9685c03bc4b8 100644 --- a/server/src/test/java/org/elasticsearch/common/lucene/search/function/MinScoreScorerTests.java +++ b/server/src/test/java/org/elasticsearch/common/lucene/search/function/MinScoreScorerTests.java @@ -19,9 +19,14 @@ package org.elasticsearch.common.lucene.search.function; +import org.apache.lucene.index.LeafReaderContext; +import org.apache.lucene.index.Term; import org.apache.lucene.search.DocIdSetIterator; +import org.apache.lucene.search.Explanation; +import org.apache.lucene.search.MatchAllDocsQuery; import org.apache.lucene.search.Scorer; import org.apache.lucene.search.TwoPhaseIterator; +import org.apache.lucene.search.Weight; import org.apache.lucene.util.LuceneTestCase; import org.apache.lucene.util.TestUtil; @@ -36,7 +41,7 @@ private static DocIdSetIterator iterator(final int... docs) { return new DocIdSetIterator() { int i = -1; - + @Override public int nextDoc() throws IOException { if (i + 1 == docs.length) { @@ -45,17 +50,17 @@ public int nextDoc() throws IOException { return docs[++i]; } } - + @Override public int docID() { return i < 0 ? -1 : i == docs.length ? NO_MORE_DOCS : docs[i]; } - + @Override public long cost() { return docs.length; } - + @Override public int advance(int target) throws IOException { return slowAdvance(target); @@ -63,9 +68,36 @@ public int advance(int target) throws IOException { }; } + private static Weight fakeWeight() { + return new Weight(new MatchAllDocsQuery()) { + @Override + public void extractTerms(Set terms) { + + } + + @Override + public Explanation explain(LeafReaderContext context, int doc) throws IOException { + return null; + } + + @Override + public Scorer scorer(LeafReaderContext context) throws IOException { + return null; + } + + @Override + public boolean isCacheable(LeafReaderContext ctx) { + return false; + } + }; + } + private static Scorer scorer(int maxDoc, final int[] docs, final float[] scores, final boolean twoPhase) { final DocIdSetIterator iterator = twoPhase ? DocIdSetIterator.all(maxDoc) : iterator(docs); - return new Scorer(null) { + return new Scorer(fakeWeight()) { + + int lastScoredDoc = -1; + public DocIdSetIterator iterator() { if (twoPhase) { return TwoPhaseIterator.asDocIdSetIterator(twoPhaseIterator()); @@ -77,12 +109,12 @@ public DocIdSetIterator iterator() { public TwoPhaseIterator twoPhaseIterator() { if (twoPhase) { return new TwoPhaseIterator(iterator) { - + @Override public boolean matches() throws IOException { return Arrays.binarySearch(docs, iterator.docID()) >= 0; } - + @Override public float matchCost() { return 10; @@ -100,6 +132,8 @@ public int docID() { @Override public float score() throws IOException { + assertNotEquals("score() called twice on doc " + docID(), lastScoredDoc, docID()); + lastScoredDoc = docID(); final int idx = Arrays.binarySearch(docs, docID()); return scores[idx]; } @@ -130,7 +164,7 @@ public void doTestRandom(boolean twoPhase) throws IOException { } Scorer scorer = scorer(maxDoc, docs, scores, twoPhase); final float minScore = random().nextFloat(); - Scorer minScoreScorer = new MinScoreScorer(null, scorer, minScore); + Scorer minScoreScorer = new MinScoreScorer(fakeWeight(), scorer, minScore); int doc = -1; while (doc != DocIdSetIterator.NO_MORE_DOCS) { final int target; @@ -152,7 +186,7 @@ public void doTestRandom(boolean twoPhase) throws IOException { assertEquals(DocIdSetIterator.NO_MORE_DOCS, doc); } else { assertEquals(docs[idx], doc); - assertEquals(scores[idx], scorer.score(), 0f); + assertEquals(scores[idx], minScoreScorer.score(), 0f); } } } diff --git a/server/src/test/java/org/elasticsearch/search/aggregations/MultiBucketCollectorTests.java b/server/src/test/java/org/elasticsearch/search/aggregations/MultiBucketCollectorTests.java index e3fe39db95246..bc8070d7ae40f 100644 --- a/server/src/test/java/org/elasticsearch/search/aggregations/MultiBucketCollectorTests.java +++ b/server/src/test/java/org/elasticsearch/search/aggregations/MultiBucketCollectorTests.java @@ -24,19 +24,16 @@ import org.apache.lucene.index.LeafReaderContext; import org.apache.lucene.index.RandomIndexWriter; import org.apache.lucene.search.CollectionTerminatedException; -import org.apache.lucene.search.DocIdSetIterator; import org.apache.lucene.search.IndexSearcher; import org.apache.lucene.search.MatchAllDocsQuery; +import org.apache.lucene.search.Scorable; import org.apache.lucene.search.ScoreMode; -import org.apache.lucene.search.Scorer; -import org.apache.lucene.search.Weight; import org.apache.lucene.store.Directory; import org.elasticsearch.test.ESTestCase; import java.io.IOException; import java.util.ArrayList; import java.util.Arrays; -import java.util.Collection; import java.util.Collections; import java.util.HashMap; import java.util.List; @@ -44,14 +41,10 @@ import java.util.concurrent.atomic.AtomicBoolean; public class MultiBucketCollectorTests extends ESTestCase { - private static class FakeScorer extends Scorer { + private static class ScoreAndDoc extends Scorable { float score; int doc = -1; - FakeScorer() { - super(null); - } - @Override public int docID() { return doc; @@ -61,26 +54,6 @@ public int docID() { public float score() { return score; } - - @Override - public DocIdSetIterator iterator() { - throw new UnsupportedOperationException(); - } - - @Override - public float getMaxScore(int upTo) throws IOException { - return Float.MAX_VALUE; - } - - @Override - public Weight getWeight() { - throw new UnsupportedOperationException(); - } - - @Override - public Collection getChildren() { - throw new UnsupportedOperationException(); - } } private static class TerminateAfterBucketCollector extends BucketCollector { @@ -171,7 +144,7 @@ public LeafBucketCollector getLeafCollector(LeafReaderContext context) throws IO final LeafBucketCollector leafCollector = in.getLeafCollector(context); return new LeafBucketCollectorBase(leafCollector, null) { @Override - public void setScorer(Scorer scorer) throws IOException { + public void setScorer(Scorable scorer) throws IOException { super.setScorer(scorer); setScorerCalled.set(true); } @@ -235,7 +208,7 @@ public void testSetScorerAfterCollectionTerminated() throws IOException { collector1 = new TerminateAfterBucketCollector(collector1, 1); collector2 = new TerminateAfterBucketCollector(collector2, 2); - Scorer scorer = new FakeScorer(); + Scorable scorer = new ScoreAndDoc(); List collectors = Arrays.asList(collector1, collector2); Collections.shuffle(collectors, random()); diff --git a/server/src/test/java/org/elasticsearch/search/aggregations/support/ScriptValuesTests.java b/server/src/test/java/org/elasticsearch/search/aggregations/support/ScriptValuesTests.java index 1915857302cd3..6f2bedbdd3712 100644 --- a/server/src/test/java/org/elasticsearch/search/aggregations/support/ScriptValuesTests.java +++ b/server/src/test/java/org/elasticsearch/search/aggregations/support/ScriptValuesTests.java @@ -20,7 +20,7 @@ package org.elasticsearch.search.aggregations.support; import com.carrotsearch.randomizedtesting.generators.RandomStrings; -import org.apache.lucene.search.Scorer; +import org.apache.lucene.search.Scorable; import org.apache.lucene.util.BytesRef; import org.elasticsearch.script.SearchScript; import org.elasticsearch.search.aggregations.support.values.ScriptBytesValues; @@ -59,7 +59,7 @@ public Object run() { } @Override - public void setScorer(Scorer scorer) { + public void setScorer(Scorable scorer) { } @Override diff --git a/server/src/test/java/org/elasticsearch/search/slice/DocValuesSliceQueryTests.java b/server/src/test/java/org/elasticsearch/search/slice/DocValuesSliceQueryTests.java index 70eb0266eea38..76807f4722afc 100644 --- a/server/src/test/java/org/elasticsearch/search/slice/DocValuesSliceQueryTests.java +++ b/server/src/test/java/org/elasticsearch/search/slice/DocValuesSliceQueryTests.java @@ -27,11 +27,11 @@ import org.apache.lucene.index.IndexReader; import org.apache.lucene.index.LeafReaderContext; import org.apache.lucene.index.RandomIndexWriter; -import org.apache.lucene.search.IndexSearcher; import org.apache.lucene.search.Collector; +import org.apache.lucene.search.IndexSearcher; import org.apache.lucene.search.LeafCollector; -import org.apache.lucene.search.Scorer; import org.apache.lucene.search.QueryUtils; +import org.apache.lucene.search.Scorable; import org.apache.lucene.search.ScoreMode; import org.apache.lucene.store.Directory; import org.apache.lucene.util.NumericUtils; @@ -99,7 +99,7 @@ public void testSearch() throws Exception { public LeafCollector getLeafCollector(LeafReaderContext context) throws IOException { return new LeafCollector() { @Override - public void setScorer(Scorer scorer) throws IOException { + public void setScorer(Scorable scorer) throws IOException { } @Override diff --git a/server/src/test/java/org/elasticsearch/search/slice/TermsSliceQueryTests.java b/server/src/test/java/org/elasticsearch/search/slice/TermsSliceQueryTests.java index 9ae4b9bc7daf5..881dc6f9587af 100644 --- a/server/src/test/java/org/elasticsearch/search/slice/TermsSliceQueryTests.java +++ b/server/src/test/java/org/elasticsearch/search/slice/TermsSliceQueryTests.java @@ -26,11 +26,11 @@ import org.apache.lucene.index.IndexReader; import org.apache.lucene.index.LeafReaderContext; import org.apache.lucene.index.RandomIndexWriter; -import org.apache.lucene.search.IndexSearcher; import org.apache.lucene.search.Collector; +import org.apache.lucene.search.IndexSearcher; import org.apache.lucene.search.LeafCollector; -import org.apache.lucene.search.Scorer; import org.apache.lucene.search.QueryUtils; +import org.apache.lucene.search.Scorable; import org.apache.lucene.search.ScoreMode; import org.apache.lucene.store.Directory; import org.apache.lucene.util.BytesRef; @@ -92,7 +92,7 @@ public void testSearch() throws Exception { public LeafCollector getLeafCollector(LeafReaderContext context) throws IOException { return new LeafCollector() { @Override - public void setScorer(Scorer scorer) throws IOException { + public void setScorer(Scorable scorer) throws IOException { } @Override diff --git a/test/framework/src/main/java/org/elasticsearch/script/MockScriptEngine.java b/test/framework/src/main/java/org/elasticsearch/script/MockScriptEngine.java index 71d40a7b86ab6..be77846b2ba34 100644 --- a/test/framework/src/main/java/org/elasticsearch/script/MockScriptEngine.java +++ b/test/framework/src/main/java/org/elasticsearch/script/MockScriptEngine.java @@ -20,7 +20,7 @@ package org.elasticsearch.script; import org.apache.lucene.index.LeafReaderContext; -import org.apache.lucene.search.Scorer; +import org.apache.lucene.search.Scorable; import org.elasticsearch.index.similarity.ScriptedSimilarity.Doc; import org.elasticsearch.index.similarity.ScriptedSimilarity.Field; import org.elasticsearch.index.similarity.ScriptedSimilarity.Query; @@ -334,7 +334,7 @@ public void setNextVar(String name, Object value) { } @Override - public void setScorer(Scorer scorer) { + public void setScorer(Scorable scorer) { ctx.put("_score", new ScoreAccessor(scorer)); } @@ -553,7 +553,7 @@ public boolean needs_score() { @Override public ScoreScript newInstance(LeafReaderContext ctx) throws IOException { - Scorer[] scorerHolder = new Scorer[1]; + Scorable[] scorerHolder = new Scorable[1]; return new ScoreScript(params, lookup, ctx) { @Override public double execute() { @@ -566,7 +566,7 @@ public double execute() { } @Override - public void setScorer(Scorer scorer) { + public void setScorer(Scorable scorer) { scorerHolder[0] = scorer; } }; diff --git a/x-pack/plugin/sql/sql-action/licenses/lucene-core-8.0.0-snapshot-4d78db26be.jar.sha1 b/x-pack/plugin/sql/sql-action/licenses/lucene-core-8.0.0-snapshot-4d78db26be.jar.sha1 deleted file mode 100644 index 683b585bb2f61..0000000000000 --- a/x-pack/plugin/sql/sql-action/licenses/lucene-core-8.0.0-snapshot-4d78db26be.jar.sha1 +++ /dev/null @@ -1 +0,0 @@ -126faacb28d1b8cc1ab81d702973d057892120d1 \ No newline at end of file diff --git a/x-pack/plugin/sql/sql-action/licenses/lucene-core-8.0.0-snapshot-66c671ea80.jar.sha1 b/x-pack/plugin/sql/sql-action/licenses/lucene-core-8.0.0-snapshot-66c671ea80.jar.sha1 new file mode 100644 index 0000000000000..50a21f5c504a2 --- /dev/null +++ b/x-pack/plugin/sql/sql-action/licenses/lucene-core-8.0.0-snapshot-66c671ea80.jar.sha1 @@ -0,0 +1 @@ +06c1e4fa838807059d27aaf5405cfdfe7303369c \ No newline at end of file