Skip to content

Commit a4e1627

Browse files
committed
Merge branch 'main' of github.com:elastic/elasticsearch into es-111747
2 parents bad9754 + 2e2fe7d commit a4e1627

File tree

54 files changed

+484
-330
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+484
-330
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
---
2+
name: Comment on PR for .asciidoc changes
3+
4+
on:
5+
# We need to use pull_request_target to be able to comment on PRs from forks
6+
pull_request_target:
7+
types:
8+
- synchronize
9+
- opened
10+
- reopened
11+
branches:
12+
- main
13+
- master
14+
- "9.0"
15+
16+
jobs:
17+
comment-on-asciidoc-change:
18+
permissions:
19+
contents: read
20+
pull-requests: write
21+
uses: elastic/docs-builder/.github/workflows/comment-on-asciidoc-changes.yml@main

build-tools-internal/version.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
elasticsearch = 9.0.0
2-
lucene = 10.0.0
2+
lucene = 10.1.0
33

44
bundled_jdk_vendor = openjdk
55
bundled_jdk = 23+37@3c5b90190c68498b986a97f276efd28a

docs/Versions.asciidoc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11

22
include::{docs-root}/shared/versions/stack/{source_branch}.asciidoc[]
33

4-
:lucene_version: 10.0.0
5-
:lucene_version_path: 10_0_0
4+
:lucene_version: 10.1.0
5+
:lucene_version_path: 10_1_0
66
:jdk: 11.0.2
77
:jdk_major: 11
88
:build_type: tar

docs/changelog/119308.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
pr: 119308
2+
summary: Upgrade to Lucene 10.1.0
3+
area: Search
4+
type: upgrade
5+
issues: []

docs/reference/search/profile.asciidoc

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ The API returns the following result:
176176
"time_in_nanos": 775274,
177177
"children" : [
178178
{
179-
"name": "SimpleTopScoreDocCollector",
179+
"name": "TopScoreDocCollector",
180180
"reason": "search_top_hits",
181181
"time_in_nanos": 775274
182182
}
@@ -537,7 +537,7 @@ Looking at the previous example:
537537
"time_in_nanos": 775274,
538538
"children" : [
539539
{
540-
"name": "SimpleTopScoreDocCollector",
540+
"name": "TopScoreDocCollector",
541541
"reason": "search_top_hits",
542542
"time_in_nanos": 775274
543543
}
@@ -551,7 +551,7 @@ Looking at the previous example:
551551

552552

553553
We see a top-level collector named `QueryPhaseCollector` which holds a child
554-
`SimpleTopScoreDocCollector`. `SimpleTopScoreDocCollector` is the default
554+
`TopScoreDocCollector`. `TopScoreDocCollector` is the default
555555
"scoring and sorting" `Collector` used by {es}. The `reason` field attempts
556556
to give a plain English description of the class name. The `time_in_nanos`
557557
is similar to the time in the Query tree: a wall-clock time inclusive of all
@@ -751,7 +751,7 @@ The API returns the following result:
751751
"time_in_nanos": 1945072,
752752
"children": [
753753
{
754-
"name": "SimpleTopScoreDocCollector",
754+
"name": "TopScoreDocCollector",
755755
"reason": "search_top_hits",
756756
"time_in_nanos": 22577
757757
},
@@ -788,7 +788,7 @@ major portions of the query are represented:
788788
2. The second `TermQuery` (message:search) represents the `post_filter` query.
789789

790790
The Collector tree is fairly straightforward, showing how a single
791-
QueryPhaseCollector that holds the normal scoring SimpleTopScoreDocCollector
791+
QueryPhaseCollector that holds the normal scoring TopScoreDocCollector
792792
used to collect top hits, as well as BucketCollectorWrapper to run all scoped
793793
aggregations.
794794

@@ -1332,7 +1332,7 @@ One of the `dfs.knn` sections for a shard looks like the following:
13321332
"rewrite_time" : 1275732,
13331333
"collector" : [
13341334
{
1335-
"name" : "SimpleTopScoreDocCollector",
1335+
"name" : "TopScoreDocCollector",
13361336
"reason" : "search_top_hits",
13371337
"time_in_nanos" : 17163
13381338
}

gradle/verification-metadata.xml

Lines changed: 125 additions & 75 deletions
Large diffs are not rendered by default.

modules/mapper-extras/src/main/java/org/elasticsearch/index/mapper/extras/SourceConfirmedTextQuery.java

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import org.apache.lucene.analysis.Analyzer;
1313
import org.apache.lucene.index.FieldInvertState;
1414
import org.apache.lucene.index.LeafReaderContext;
15+
import org.apache.lucene.index.NumericDocValues;
1516
import org.apache.lucene.index.Term;
1617
import org.apache.lucene.index.TermStates;
1718
import org.apache.lucene.index.memory.MemoryIndex;
@@ -23,7 +24,6 @@
2324
import org.apache.lucene.search.DocIdSetIterator;
2425
import org.apache.lucene.search.Explanation;
2526
import org.apache.lucene.search.IndexSearcher;
26-
import org.apache.lucene.search.LeafSimScorer;
2727
import org.apache.lucene.search.MatchAllDocsQuery;
2828
import org.apache.lucene.search.MatchNoDocsQuery;
2929
import org.apache.lucene.search.Matches;
@@ -214,7 +214,6 @@ public Weight createWeight(IndexSearcher searcher, ScoreMode scoreMode, float bo
214214
// No need to ever look at the _source for non-scoring term queries
215215
return in.createWeight(searcher, scoreMode, boost);
216216
}
217-
218217
// We use a LinkedHashSet here to preserve the ordering of terms to ensure that
219218
// later summing of float scores per term is consistent
220219
final Set<Term> terms = new LinkedHashSet<>();
@@ -267,6 +266,7 @@ public boolean isCacheable(LeafReaderContext ctx) {
267266

268267
@Override
269268
public Explanation explain(LeafReaderContext context, int doc) throws IOException {
269+
NumericDocValues norms = context.reader().getNormValues(field);
270270
RuntimePhraseScorer scorer = (RuntimePhraseScorer) scorerSupplier(context).get(0);
271271
if (scorer == null) {
272272
return Explanation.noMatch("No matching phrase");
@@ -277,8 +277,7 @@ public Explanation explain(LeafReaderContext context, int doc) throws IOExceptio
277277
}
278278
float phraseFreq = scorer.freq();
279279
Explanation freqExplanation = Explanation.match(phraseFreq, "phraseFreq=" + phraseFreq);
280-
final LeafSimScorer leafSimScorer = new LeafSimScorer(simScorer, context.reader(), field, scoreMode.needsScores());
281-
Explanation scoreExplanation = leafSimScorer.explain(doc, freqExplanation);
280+
Explanation scoreExplanation = simScorer.explain(freqExplanation, getNormValue(norms, doc));
282281
return Explanation.match(
283282
scoreExplanation.getValue(),
284283
"weight(" + getQuery() + " in " + doc + ") [" + searcher.getSimilarity().getClass().getSimpleName() + "], result of:",
@@ -297,9 +296,9 @@ public ScorerSupplier scorerSupplier(LeafReaderContext context) throws IOExcepti
297296
public Scorer get(long leadCost) throws IOException {
298297
final Scorer approximationScorer = approximationSupplier.get(leadCost);
299298
final DocIdSetIterator approximation = approximationScorer.iterator();
300-
final LeafSimScorer leafSimScorer = new LeafSimScorer(simScorer, context.reader(), field, scoreMode.needsScores());
301299
final CheckedIntFunction<List<Object>, IOException> valueFetcher = valueFetcherProvider.apply(context);
302-
return new RuntimePhraseScorer(approximation, leafSimScorer, valueFetcher, field, in);
300+
NumericDocValues norms = context.reader().getNormValues(field);
301+
return new RuntimePhraseScorer(approximation, simScorer, norms, valueFetcher, field, in);
303302
}
304303

305304
@Override
@@ -335,12 +334,23 @@ public Matches matches(LeafReaderContext context, int doc) throws IOException {
335334
};
336335
}
337336

337+
private static long getNormValue(NumericDocValues norms, int doc) throws IOException {
338+
if (norms != null) {
339+
boolean found = norms.advanceExact(doc);
340+
assert found;
341+
return norms.longValue();
342+
} else {
343+
return 1L; // default norm
344+
}
345+
}
346+
338347
private class RuntimePhraseScorer extends Scorer {
339-
private final LeafSimScorer scorer;
348+
private final SimScorer scorer;
340349
private final CheckedIntFunction<List<Object>, IOException> valueFetcher;
341350
private final String field;
342351
private final Query query;
343352
private final TwoPhaseIterator twoPhase;
353+
private final NumericDocValues norms;
344354

345355
private final MemoryIndexEntry cacheEntry = new MemoryIndexEntry();
346356

@@ -349,12 +359,14 @@ private class RuntimePhraseScorer extends Scorer {
349359

350360
private RuntimePhraseScorer(
351361
DocIdSetIterator approximation,
352-
LeafSimScorer scorer,
362+
SimScorer scorer,
363+
NumericDocValues norms,
353364
CheckedIntFunction<List<Object>, IOException> valueFetcher,
354365
String field,
355366
Query query
356367
) {
357368
this.scorer = scorer;
369+
this.norms = norms;
358370
this.valueFetcher = valueFetcher;
359371
this.field = field;
360372
this.query = query;
@@ -386,12 +398,12 @@ public TwoPhaseIterator twoPhaseIterator() {
386398

387399
@Override
388400
public float getMaxScore(int upTo) throws IOException {
389-
return scorer.getSimScorer().score(Float.MAX_VALUE, 1L);
401+
return scorer.score(Float.MAX_VALUE, 1L);
390402
}
391403

392404
@Override
393405
public float score() throws IOException {
394-
return scorer.score(docID(), freq());
406+
return scorer.score(freq(), getNormValue(norms, doc));
395407
}
396408

397409
@Override

muted-tests.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -352,6 +352,17 @@ tests:
352352
- class: org.elasticsearch.upgrades.VectorSearchIT
353353
method: testBBQVectorSearch {upgradedNodes=3}
354354
issue: https://github.com/elastic/elasticsearch/issues/121273
355+
- class: org.elasticsearch.xpack.security.authc.ldap.ActiveDirectorySessionFactoryTests
356+
issue: https://github.com/elastic/elasticsearch/issues/121285
357+
- class: org.elasticsearch.smoketest.DocsClientYamlTestSuiteIT
358+
method: test {yaml=reference/snapshot-restore/apis/get-snapshot-api/line_357}
359+
issue: https://github.com/elastic/elasticsearch/issues/121287
360+
- class: org.elasticsearch.test.rest.yaml.RcsCcsCommonYamlTestSuiteIT
361+
method: test {p0=search.vectors/42_knn_search_int4_flat/Vector similarity with filter only}
362+
issue: https://github.com/elastic/elasticsearch/issues/115475
363+
- class: org.elasticsearch.smoketest.DocsClientYamlTestSuiteIT
364+
method: test {yaml=reference/index-modules/slowlog/line_102}
365+
issue: https://github.com/elastic/elasticsearch/issues/121288
355366

356367
# Examples:
357368
#

rest-api-spec/build.gradle

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ tasks.named("precommit").configure {
5757
tasks.named("yamlRestCompatTestTransform").configure ({ task ->
5858
task.replaceValueInMatch("profile.shards.0.dfs.knn.0.query.0.description", "DocAndScoreQuery[0,...][0.009673266,...],0.009673266", "dfs knn vector profiling")
5959
task.replaceValueInMatch("profile.shards.0.dfs.knn.0.query.0.description", "DocAndScoreQuery[0,...][0.009673266,...],0.009673266", "dfs knn vector profiling with vector_operations_count")
60+
task.replaceValueInMatch("profile.shards.0.dfs.knn.0.collector.0.name", "TopScoreDocCollector", "dfs knn vector profiling")
61+
task.replaceValueInMatch("profile.shards.0.dfs.knn.0.collector.0.name", "TopScoreDocCollector", "dfs knn vector profiling with vector_operations_count")
6062
task.skipTest("cat.aliases/10_basic/Deprecated local parameter", "CAT APIs not covered by compatibility policy")
6163
task.skipTest("cat.shards/10_basic/Help", "sync_id is removed in 9.0")
6264
task.skipTest("search/500_date_range/from, to, include_lower, include_upper deprecated", "deprecated parameters are removed in 9.0")

rest-api-spec/src/yamlRestTest/resources/rest-api-spec/test/search/370_profile.yml

Lines changed: 41 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,6 @@ dfs knn vector profiling:
230230
- gt: { profile.shards.0.dfs.knn.0.query.0.breakdown.create_weight: 0 }
231231
- gt: { profile.shards.0.dfs.knn.0.query.0.breakdown.create_weight_count: 0 }
232232
- gt: { profile.shards.0.dfs.knn.0.rewrite_time: 0 }
233-
- match: { profile.shards.0.dfs.knn.0.collector.0.name: "SimpleTopScoreDocCollector" }
234233
- match: { profile.shards.0.dfs.knn.0.collector.0.reason: "search_top_hits" }
235234
- gt: { profile.shards.0.dfs.knn.0.collector.0.time_in_nanos: 0 }
236235

@@ -275,6 +274,47 @@ dfs knn vector profiling description:
275274
- match: { hits.total.value: 1 }
276275
- match: { profile.shards.0.dfs.knn.0.query.0.description: "DocAndScoreQuery[0,...][0.009673266,...],0.009673266" }
277276

277+
---
278+
dfs knn vector profiling collector name:
279+
- requires:
280+
cluster_features: "lucene_10_1_upgrade"
281+
reason: collector name changed with lucene 10.1
282+
283+
- do:
284+
indices.create:
285+
index: images
286+
body:
287+
settings:
288+
index.number_of_shards: 1
289+
mappings:
290+
properties:
291+
image:
292+
type: "dense_vector"
293+
dims: 3
294+
index: true
295+
similarity: "l2_norm"
296+
297+
- do:
298+
index:
299+
index: images
300+
id: "1"
301+
refresh: true
302+
body:
303+
image: [1, 5, -20]
304+
305+
- do:
306+
search:
307+
index: images
308+
body:
309+
profile: true
310+
knn:
311+
field: "image"
312+
query_vector: [-5, 9, -12]
313+
k: 1
314+
num_candidates: 100
315+
316+
- match: { profile.shards.0.dfs.knn.0.collector.0.name: "TopScoreDocCollector" }
317+
278318
---
279319
dfs knn vector profiling with vector_operations_count:
280320
- requires:
@@ -335,7 +375,6 @@ dfs knn vector profiling with vector_operations_count:
335375
- gt: { profile.shards.0.dfs.knn.0.query.0.breakdown.create_weight: 0 }
336376
- gt: { profile.shards.0.dfs.knn.0.query.0.breakdown.create_weight_count: 0 }
337377
- gt: { profile.shards.0.dfs.knn.0.rewrite_time: 0 }
338-
- match: { profile.shards.0.dfs.knn.0.collector.0.name: "SimpleTopScoreDocCollector" }
339378
- match: { profile.shards.0.dfs.knn.0.collector.0.reason: "search_top_hits" }
340379
- gt: { profile.shards.0.dfs.knn.0.collector.0.time_in_nanos: 0 }
341380

0 commit comments

Comments
 (0)