Skip to content

Commit 92adad2

Browse files
Merge branch 'main' into es-12656-linked-proj-cfg
2 parents 62b42a1 + c9b2a46 commit 92adad2

File tree

21 files changed

+684
-57
lines changed

21 files changed

+684
-57
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
steps:
2+
- label: ":pipeline: Generate steps"
3+
command: bash .buildkite/scripts/generate-pr-performance-benchmark.sh | buildkite-agent pipeline upload

.buildkite/pipelines/pull-request/performance-benchmark.yml

Lines changed: 0 additions & 3 deletions
This file was deleted.

.buildkite/pull-requests.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@
2727
"set_commit_status": false,
2828
"build_on_commit": false,
2929
"build_on_comment": true,
30-
"trigger_comment_regex": "^(buildkite|@elastic(search)?machine) benchmark this with (?<benchmark>\\w+)( please)?$"
30+
"target_branch": "main",
31+
"trigger_comment_regex": "^(buildkite|@elastic(search)?machine) benchmark this with (?<benchmark>\\S+)( please)?$"
3132
}
3233
]
3334
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
#!/bin/bash
2+
3+
set -euo pipefail
4+
5+
env_id_baseline=$(python3 -c 'import uuid; print(uuid.uuid4())')
6+
env_id_contender=$(python3 -c 'import uuid; print(uuid.uuid4())')
7+
merge_base=$(git merge-base "${GITHUB_PR_TARGET_BRANCH}" HEAD)
8+
9+
buildkite-agent meta-data set pr_comment:custom-body:body \
10+
"This build attempted two ${GITHUB_PR_COMMENT_VAR_BENCHMARK} benchmarks to evaluate performance impact of this PR."
11+
buildkite-agent meta-data set pr_comment:custom-baseline:head \
12+
"* Baseline: ${merge_base} (env ID ${env_id_baseline})"
13+
buildkite-agent meta-data set pr_comment:custom-contender:head \
14+
"* Contender: ${GITHUB_PR_TRIGGERED_SHA} (env ID ${env_id_contender})"
15+
16+
cat << _EOF_
17+
steps:
18+
- label: Trigger baseline benchmark
19+
trigger: elasticsearch-performance-esbench-pr
20+
build:
21+
message: Baseline benchmark for PR${GITHUB_PR_NUMBER}
22+
branch: master
23+
env:
24+
CONFIGURATION_NAME: ${GITHUB_PR_COMMENT_VAR_BENCHMARK}
25+
ENV_ID: ${env_id_baseline}
26+
REVISION: ${merge_base}
27+
- label: Trigger contender benchmark
28+
trigger: elasticsearch-performance-esbench-pr
29+
build:
30+
message: Contender benchmark for PR${GITHUB_PR_NUMBER}
31+
branch: master
32+
env:
33+
CONFIGURATION_NAME: ${GITHUB_PR_COMMENT_VAR_BENCHMARK}
34+
ENV_ID: ${env_id_contender}
35+
ES_REPO_URL: https://github.com/${GITHUB_PR_OWNER}/${GITHUB_PR_REPO}.git
36+
REVISION: ${GITHUB_PR_TRIGGERED_SHA}
37+
- wait: ~
38+
- label: Modify PR comment
39+
command: buildkite-agent meta-data set pr_comment:custom-comparison:head "* [Benchmark results](<https://esbench-metrics.kb.us-east-2.aws.elastic-cloud.com:9243/app/dashboards#/view/d9079962-5866-49ef-b9f5-145f2141cd31?_a=(query:(language:kuery,query:'user-tags.env-id:${env_id_baseline} or user-tags.env-id:${env_id_contender}'))>)"
40+
_EOF_

catalog-info.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ spec:
323323
name: elasticsearch / pull-request / performance-benchmark
324324
spec:
325325
repository: elastic/elasticsearch
326-
pipeline_file: .buildkite/pipelines/pull-request/performance-benchmark.yml
326+
pipeline_file: .buildkite/pipelines/pull-request-performance-benchmark.yml
327327
env:
328328
ELASTIC_PR_COMMENTS_ENABLED: "true"
329329
ELASTIC_SLACK_NOTIFICATIONS_ENABLED: "true"

docs/changelog/74274.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
pr: 74274
2+
summary: Introduce new rescorer based on script
3+
area: Search
4+
type: feature
5+
issues:
6+
- 52338

muted-tests.yml

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -299,12 +299,6 @@ tests:
299299
- class: org.elasticsearch.compute.operator.LimitOperatorTests
300300
method: testEarlyTermination
301301
issue: https://github.com/elastic/elasticsearch/issues/128721
302-
- class: org.elasticsearch.xpack.esql.qa.single_node.GenerativeForkIT
303-
method: test {csv-spec:lookup-join.EnrichLookupStatsBug}
304-
issue: https://github.com/elastic/elasticsearch/issues/129228
305-
- class: org.elasticsearch.xpack.esql.qa.single_node.GenerativeForkIT
306-
method: test {lookup-join.MultipleBatches*
307-
issue: https://github.com/elastic/elasticsearch/issues/129210
308302
- class: org.elasticsearch.entitlement.runtime.policy.FileAccessTreeTests
309303
method: testWindowsMixedCaseAccess
310304
issue: https://github.com/elastic/elasticsearch/issues/129167
@@ -471,9 +465,6 @@ tests:
471465
- class: org.elasticsearch.xpack.ml.integration.RevertModelSnapshotIT
472466
method: testRevertModelSnapshot
473467
issue: https://github.com/elastic/elasticsearch/issues/132733
474-
- class: org.elasticsearch.xpack.esql.qa.single_node.GenerativeForkIT
475-
method: test {csv-spec:lookup-join.MvJoinKeyFromRowExpanded}
476-
issue: https://github.com/elastic/elasticsearch/issues/132778
477468
- class: org.elasticsearch.gradle.internal.transport.TransportVersionManagementPluginFuncTest
478469
method: definitions have primary ids which cannot change
479470
issue: https://github.com/elastic/elasticsearch/issues/132788
@@ -615,6 +606,12 @@ tests:
615606
- class: org.elasticsearch.test.rest.yaml.RcsCcsCommonYamlTestSuiteIT
616607
method: test {p0=search.vectors/100_knn_nested_search/nested kNN search inner_hits & profiling}
617608
issue: https://github.com/elastic/elasticsearch/issues/133273
609+
- class: org.elasticsearch.xpack.security.authc.AuthenticationServiceTests
610+
method: testInvalidToken
611+
issue: https://github.com/elastic/elasticsearch/issues/133328
612+
- class: org.elasticsearch.test.rest.yaml.RcsCcsCommonYamlTestSuiteIT
613+
method: test {p0=search/160_exists_query/Test exists query on unmapped byte field}
614+
issue: https://github.com/elastic/elasticsearch/issues/133331
618615

619616
# Examples:
620617
#
Lines changed: 277 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,277 @@
1+
setup:
2+
- requires:
3+
cluster_features: [ "search.rescore.script" ]
4+
reason: "Test requires feature 'search.rescore.script' to test script rescore"
5+
test_runner_features: "close_to"
6+
- skip:
7+
reason: "contains is a newly added assertion"
8+
features: contains
9+
10+
- do:
11+
indices.create:
12+
index: books
13+
body:
14+
settings:
15+
number_of_shards: 1
16+
mappings:
17+
properties:
18+
title:
19+
type: text
20+
author:
21+
type: keyword
22+
num_likes:
23+
type: integer
24+
25+
- do:
26+
bulk:
27+
index: books
28+
refresh: true
29+
body:
30+
- '{"index": {"_id": "1"}}'
31+
- '{"title": "The Ethics of Ambiguity", "author": "Simone de Beauvoir", "num_likes": 150}'
32+
- '{"index": {"_id": "2"}}'
33+
- '{"title": "The Ethics of Being and Nothingness", "author": "Jean-Paul Sartre", "num_likes": 250}'
34+
- '{"index": {"_id": "3"}}'
35+
- '{"title": "The Ambiguity of The Second Sex", "author": "Simone de Beauvoir", "num_likes": 300}'
36+
- '{"index": {"_id": "4"}}'
37+
- '{"title": "The Ethics of Nausea", "author": "Jean-Paul Sartre", "num_likes": 180}'
38+
- '{"index": {"_id": "5"}}'
39+
- '{"title": "The Ambiguity in the Myth of Sisyphus", "author": "Albert Camus", "num_likes": 220}'
40+
41+
---
42+
"Basic script rescore":
43+
44+
# simple rescore script for all top docs
45+
- do:
46+
search:
47+
index: books
48+
body:
49+
query:
50+
match:
51+
title: "ethics of ambiguity"
52+
rescore:
53+
window_size: 5
54+
script:
55+
script:
56+
source: "doc['num_likes'].value * params.multiplier"
57+
params:
58+
multiplier: 10
59+
- match: { hits.total.value: 5 }
60+
- match: { hits.hits.0._id: "3" }
61+
- close_to: { hits.hits.0._score: {value: 3000, error: 0.0001} }
62+
- match: { hits.hits.1._id: "2" }
63+
- close_to: { hits.hits.1._score: {value: 2500, error: 0.0001} }
64+
- match: { hits.hits.2._id: "5" }
65+
- close_to: { hits.hits.2._score: {value: 2200, error: 0.0001} }
66+
- match: { hits.hits.3._id: "4" }
67+
- close_to: { hits.hits.3._score: {value: 1800, error: 0.0001} }
68+
- match: { hits.hits.4._id: "1" }
69+
- close_to: { hits.hits.4._score: {value: 1500, error: 0.0001} }
70+
71+
# rescore script with _score for all top docs
72+
- do:
73+
search:
74+
index: books
75+
body:
76+
query:
77+
match:
78+
title: "ethics of ambiguity"
79+
rescore:
80+
window_size: 5
81+
script:
82+
script:
83+
source: "doc['num_likes'].value * params.multiplier + _score"
84+
params:
85+
multiplier: 10
86+
- match: { hits.hits.0._id: "3" }
87+
- close_to: { hits.hits.0._score: { value: 3000.5989, error: 0.0001 } }
88+
- match: { hits.hits.1._id: "2" }
89+
- close_to: { hits.hits.1._score: { value: 2500.5989, error: 0.0001 } }
90+
- match: { hits.hits.2._id: "5" }
91+
- close_to: { hits.hits.2._score: { value: 2200.5583, error: 0.0001 } }
92+
- match: { hits.hits.3._id: "4" }
93+
- close_to: { hits.hits.3._score: { value: 1800.7003, error: 0.0001 } }
94+
- match: { hits.hits.4._id: "1" }
95+
- close_to: { hits.hits.4._score: { value: 1501.3032, error: 0.0001 } }
96+
97+
# simple rescore script for small window size
98+
- do:
99+
search:
100+
index: books
101+
body:
102+
query:
103+
match:
104+
title: "ethics of ambiguity"
105+
rescore:
106+
window_size: 3
107+
script:
108+
script:
109+
source: "doc['num_likes'].value * params.multiplier"
110+
params:
111+
multiplier: 10
112+
- match: { hits.hits.0._id: "2" }
113+
- close_to: { hits.hits.0._score: { value: 2500, error: 0.0001 } }
114+
- match: { hits.hits.1._id: "4" }
115+
- close_to: { hits.hits.1._score: { value: 1800, error: 0.0001 } }
116+
- match: { hits.hits.2._id: "1" }
117+
- close_to: { hits.hits.2._score: { value: 1500, error: 0.0001 } }
118+
- match: { hits.hits.3._id: "3" }
119+
- close_to: { hits.hits.3._score: { value: 0.59879, error: 0.0001 } }
120+
- match: { hits.hits.4._id: "5" }
121+
- close_to: { hits.hits.4._score: { value: 0.5583, error: 0.0001 } }
122+
123+
# rescore script with _score for small window size
124+
- do:
125+
search:
126+
index: books
127+
body:
128+
query:
129+
match:
130+
title: "ethics of ambiguity"
131+
rescore:
132+
window_size: 3
133+
script:
134+
script:
135+
source: "doc['num_likes'].value * params.multiplier + _score"
136+
params:
137+
multiplier: 10
138+
- match: { hits.hits.0._id: "2" }
139+
- close_to: { hits.hits.0._score: { value: 2500.5989, error: 0.0001 } }
140+
- match: { hits.hits.1._id: "4" }
141+
- close_to: { hits.hits.1._score: { value: 1800.7003, error: 0.0001 } }
142+
- match: { hits.hits.2._id: "1" }
143+
- close_to: { hits.hits.2._score: { value: 1501.3032, error: 0.0001 } }
144+
- match: { hits.hits.3._id: "3" }
145+
- close_to: { hits.hits.3._score: { value: 0.59879, error: 0.0001 } }
146+
- match: { hits.hits.4._id: "5" }
147+
- close_to: { hits.hits.4._score: { value: 0.5583, error: 0.0001 } }
148+
149+
---
150+
"Multiple script rescore":
151+
- do:
152+
search:
153+
index: books
154+
body:
155+
query:
156+
match:
157+
title: "ethics of ambiguity"
158+
rescore:
159+
- window_size: 3
160+
script:
161+
script:
162+
source: "doc['num_likes'].value * params.multiplier + _score"
163+
params:
164+
multiplier: 10
165+
- window_size: 2
166+
script:
167+
script:
168+
source: "_score * params.factor"
169+
params:
170+
factor: 10
171+
- match: { hits.hits.0._id: "2" }
172+
- close_to: { hits.hits.0._score: { value: 25005.989, error: 0.005 } } # rescored by 1st and 2nd scripts
173+
- match: { hits.hits.1._id: "4" }
174+
- close_to: { hits.hits.1._score: { value: 18007.0039, error: 0.005 } } # rescored by 1st and 2nd scripts
175+
- match: { hits.hits.2._id: "1" }
176+
- close_to: { hits.hits.2._score: { value: 1501.3032, error: 0.0005 } } # rescored by 1st script
177+
- match: { hits.hits.3._id: "3" }
178+
- close_to: { hits.hits.3._score: { value: 0.59879, error: 0.0001 } } # not rescored
179+
- match: { hits.hits.4._id: "5" }
180+
- close_to: { hits.hits.4._score: { value: 0.5583, error: 0.0001 } } # not rescored
181+
182+
---
183+
"Rescore Script With Explanation":
184+
- do:
185+
search:
186+
index: books
187+
explain: true
188+
body:
189+
query:
190+
match:
191+
title: "ethics of ambiguity"
192+
rescore:
193+
window_size: 3
194+
script:
195+
script:
196+
source: "doc['num_likes'].value * params.multiplier + _score"
197+
params:
198+
multiplier: 10
199+
- match: { hits.total.value: 5 }
200+
201+
# hit went through rescore
202+
- contains: { hits.hits.0._explanation.description: "script score function" }
203+
- close_to: { hits.hits.0._explanation.value: { value: 2500.5989, error: 0.0001 } }
204+
- match: { hits.hits.0._explanation.details.0.description: '_score: ' }
205+
- close_to: { hits.hits.0._explanation.details.0.value: { value: 0.5987902, error: 0.0001 } }
206+
207+
# hit did not go through rescore
208+
- match: { hits.hits.4._explanation.description: "sum of:" }
209+
- close_to: { hits.hits.4._explanation.value: { value: 0.5583, error: 0.0001 } }
210+
211+
212+
---
213+
"Script rescore on Multiple Segments":
214+
# update some documents to create multiple segments
215+
- do:
216+
bulk:
217+
index: books
218+
refresh: true
219+
body:
220+
- '{"update": {"_id": "1"}}'
221+
- '{"doc": {"num_likes": 300}}'
222+
- '{"update": {"_id": "3"}}'
223+
- '{"doc": {"num_likes": 150}}'
224+
225+
- do:
226+
search:
227+
index: books
228+
body:
229+
query:
230+
match:
231+
title: "ethics of ambiguity"
232+
rescore:
233+
window_size: 5
234+
script:
235+
script:
236+
source: "doc['num_likes'].value * params.multiplier + _score"
237+
params:
238+
multiplier: 10
239+
- match: { hits.total.value: 5 }
240+
- match: { hits.hits.0._id: "1" }
241+
- close_to: { hits.hits.0._score: { value: 3001.1267, error: 0.0001 } }
242+
- match: { hits.hits.1._id: "2" }
243+
- close_to: { hits.hits.1._score: { value: 2500.6064, error: 0.0001 } }
244+
- match: { hits.hits.2._id: "5" }
245+
- close_to: { hits.hits.2._score: { value: 2200.3877, error: 0.0001 } }
246+
- match: { hits.hits.3._id: "4" }
247+
- close_to: { hits.hits.3._score: { value: 1800.7106, error: 0.0001 } }
248+
- match: { hits.hits.4._id: "3" }
249+
- close_to: { hits.hits.4._score: { value: 1500.4163, error: 0.0001 } }
250+
251+
# rescore script with _score for small window size
252+
- do:
253+
search:
254+
index: books
255+
body:
256+
query:
257+
match:
258+
title: "ethics of ambiguity"
259+
rescore:
260+
window_size: 3
261+
script:
262+
script:
263+
source: "doc['num_likes'].value * params.multiplier + _score"
264+
params:
265+
multiplier: 10
266+
- match: { hits.total.value: 5 }
267+
- match: { hits.hits.0._id: "1" }
268+
- close_to: { hits.hits.0._score: { value: 3001.1267, error: 0.0001 } }
269+
- match: { hits.hits.1._id: "2" }
270+
- close_to: { hits.hits.1._score: { value: 2500.6064, error: 0.0001 } }
271+
- match: { hits.hits.2._id: "4" }
272+
- close_to: { hits.hits.2._score: { value: 1800.7106, error: 0.0001 } }
273+
- match: { hits.hits.3._id: "3" }
274+
- close_to: { hits.hits.3._score: { value: 0.41622, error: 0.0001 } }
275+
- match: { hits.hits.4._id: "5" }
276+
- close_to: { hits.hits.4._score: { value: 0.38778, error: 0.0001 } }
277+

server/src/main/java/org/elasticsearch/TransportVersions.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -366,6 +366,7 @@ static TransportVersion def(int id) {
366366
public static final TransportVersion SIMULATE_INGEST_EFFECTIVE_MAPPING = def(9_140_0_00);
367367
public static final TransportVersion RESOLVE_INDEX_MODE_ADDED = def(9_141_0_00);
368368
public static final TransportVersion DATA_STREAM_WRITE_INDEX_ONLY_SETTINGS = def(9_142_0_00);
369+
public static final TransportVersion SCRIPT_RESCORER = def(9_143_0_00);
369370

370371
/*
371372
* STOP! READ THIS FIRST! No, really,

0 commit comments

Comments
 (0)