Skip to content

Commit 72b8779

Browse files
authored
Merge branch 'main' into non-issue/rescore-vector-use-size-as-k
2 parents 1674d50 + 93aee0f commit 72b8779

File tree

65 files changed

+2617
-385
lines changed

Some content is hidden

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

65 files changed

+2617
-385
lines changed

build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/ElasticsearchJavaPlugin.java

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,15 @@
3131
import org.gradle.api.tasks.bundling.Jar;
3232
import org.gradle.api.tasks.javadoc.Javadoc;
3333
import org.gradle.external.javadoc.CoreJavadocOptions;
34+
import org.gradle.jvm.toolchain.JavaLanguageVersion;
35+
import org.gradle.jvm.toolchain.JavaToolchainService;
3436
import org.gradle.language.base.plugins.LifecycleBasePlugin;
3537

3638
import java.io.File;
3739
import java.util.Map;
3840

41+
import javax.inject.Inject;
42+
3943
import static org.elasticsearch.gradle.internal.conventions.util.Util.toStringable;
4044
import static org.elasticsearch.gradle.internal.util.ParamsUtils.loadBuildParams;
4145

@@ -44,6 +48,14 @@
4448
* common configuration for production code.
4549
*/
4650
public class ElasticsearchJavaPlugin implements Plugin<Project> {
51+
52+
private final JavaToolchainService javaToolchains;
53+
54+
@Inject
55+
ElasticsearchJavaPlugin(JavaToolchainService javaToolchains) {
56+
this.javaToolchains = javaToolchains;
57+
}
58+
4759
@Override
4860
public void apply(Project project) {
4961
project.getRootProject().getPlugins().apply(GlobalBuildInfoPlugin.class);
@@ -55,7 +67,7 @@ public void apply(Project project) {
5567
// configureConfigurations(project);
5668
configureJars(project, buildParams.get());
5769
configureJarManifest(project, buildParams.get());
58-
configureJavadoc(project);
70+
configureJavadoc(project, buildParams.get());
5971
testCompileOnlyDeps(project);
6072
}
6173

@@ -128,14 +140,18 @@ private static void configureJarManifest(Project project, BuildParameterExtensio
128140
project.getPluginManager().apply("nebula.info-jar");
129141
}
130142

131-
private static void configureJavadoc(Project project) {
143+
private void configureJavadoc(Project project, BuildParameterExtension buildParams) {
132144
project.getTasks().withType(Javadoc.class).configureEach(javadoc -> {
133145
/*
134146
* Generate docs using html5 to suppress a warning from `javadoc`
135147
* that the default will change to html5 in the future.
136148
*/
137149
CoreJavadocOptions javadocOptions = (CoreJavadocOptions) javadoc.getOptions();
138150
javadocOptions.addBooleanOption("html5", true);
151+
152+
javadoc.getJavadocTool().set(javaToolchains.javadocToolFor(spec -> {
153+
spec.getLanguageVersion().set(JavaLanguageVersion.of(buildParams.getMinimumRuntimeVersion().getMajorVersion()));
154+
}));
139155
});
140156

141157
TaskProvider<Javadoc> javadoc = project.getTasks().withType(Javadoc.class).named("javadoc");

build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/InternalDistributionBwcSetupPlugin.java

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@
1717
import org.gradle.api.Plugin;
1818
import org.gradle.api.Project;
1919
import org.gradle.api.Task;
20+
import org.gradle.api.file.FileSystemOperations;
2021
import org.gradle.api.file.ProjectLayout;
2122
import org.gradle.api.model.ObjectFactory;
2223
import org.gradle.api.plugins.JvmToolchainsPlugin;
2324
import org.gradle.api.provider.Provider;
2425
import org.gradle.api.provider.ProviderFactory;
25-
import org.gradle.api.tasks.Copy;
2626
import org.gradle.api.tasks.PathSensitivity;
2727
import org.gradle.api.tasks.TaskProvider;
2828
import org.gradle.jvm.toolchain.JavaToolchainService;
@@ -54,11 +54,17 @@ public class InternalDistributionBwcSetupPlugin implements Plugin<Project> {
5454
private final ObjectFactory objectFactory;
5555
private ProviderFactory providerFactory;
5656
private JavaToolchainService toolChainService;
57+
private FileSystemOperations fileSystemOperations;
5758

5859
@Inject
59-
public InternalDistributionBwcSetupPlugin(ObjectFactory objectFactory, ProviderFactory providerFactory) {
60+
public InternalDistributionBwcSetupPlugin(
61+
ObjectFactory objectFactory,
62+
ProviderFactory providerFactory,
63+
FileSystemOperations fileSystemOperations
64+
) {
6065
this.objectFactory = objectFactory;
6166
this.providerFactory = providerFactory;
67+
this.fileSystemOperations = fileSystemOperations;
6268
}
6369

6470
@Override
@@ -76,7 +82,8 @@ public void apply(Project project) {
7682
providerFactory,
7783
objectFactory,
7884
toolChainService,
79-
isCi
85+
isCi,
86+
fileSystemOperations
8087
);
8188
});
8289
}
@@ -88,7 +95,8 @@ private static void configureBwcProject(
8895
ProviderFactory providerFactory,
8996
ObjectFactory objectFactory,
9097
JavaToolchainService toolChainService,
91-
Boolean isCi
98+
Boolean isCi,
99+
FileSystemOperations fileSystemOperations
92100
) {
93101
ProjectLayout layout = project.getLayout();
94102
Provider<BwcVersions.UnreleasedVersionInfo> versionInfoProvider = providerFactory.provider(() -> versionInfo);
@@ -120,11 +128,18 @@ private static void configureBwcProject(
120128
List<DistributionProject> distributionProjects = resolveArchiveProjects(checkoutDir.get(), bwcVersion.get());
121129

122130
// Setup gradle user home directory
123-
project.getTasks().register("setupGradleUserHome", Copy.class, copy -> {
124-
copy.into(project.getGradle().getGradleUserHomeDir().getAbsolutePath() + "-" + project.getName());
125-
copy.from(project.getGradle().getGradleUserHomeDir().getAbsolutePath(), copySpec -> {
126-
copySpec.include("gradle.properties");
127-
copySpec.include("init.d/*");
131+
// We don't use a normal `Copy` task here as snapshotting the entire gradle user home is very expensive. This task is cheap, so
132+
// up-to-date checking doesn't buy us much
133+
project.getTasks().register("setupGradleUserHome", task -> {
134+
task.doLast(t -> {
135+
fileSystemOperations.copy(copy -> {
136+
String gradleUserHome = project.getGradle().getGradleUserHomeDir().getAbsolutePath();
137+
copy.into(gradleUserHome + "-" + project.getName());
138+
copy.from(gradleUserHome, copySpec -> {
139+
copySpec.include("gradle.properties");
140+
copySpec.include("init.d/*");
141+
});
142+
});
128143
});
129144
});
130145

build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/MrjarPlugin.java

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,14 +86,14 @@ public void apply(Project project) {
8686
configurePreviewFeatures(project, javaExtension.getSourceSets().getByName(SourceSet.TEST_SOURCE_SET_NAME), 21);
8787
for (int javaVersion : mainVersions) {
8888
String mainSourceSetName = SourceSet.MAIN_SOURCE_SET_NAME + javaVersion;
89-
SourceSet mainSourceSet = addSourceSet(project, javaExtension, mainSourceSetName, mainSourceSets, javaVersion);
89+
SourceSet mainSourceSet = addSourceSet(project, javaExtension, mainSourceSetName, mainSourceSets, javaVersion, true);
9090
configureSourceSetInJar(project, mainSourceSet, javaVersion);
9191
addJar(project, mainSourceSet, javaVersion);
9292
mainSourceSets.add(mainSourceSetName);
9393
testSourceSets.add(mainSourceSetName);
9494

9595
String testSourceSetName = SourceSet.TEST_SOURCE_SET_NAME + javaVersion;
96-
SourceSet testSourceSet = addSourceSet(project, javaExtension, testSourceSetName, testSourceSets, javaVersion);
96+
SourceSet testSourceSet = addSourceSet(project, javaExtension, testSourceSetName, testSourceSets, javaVersion, false);
9797
testSourceSets.add(testSourceSetName);
9898
createTestTask(project, buildParams, testSourceSet, javaVersion, mainSourceSets);
9999
}
@@ -121,7 +121,8 @@ private SourceSet addSourceSet(
121121
JavaPluginExtension javaExtension,
122122
String sourceSetName,
123123
List<String> parentSourceSets,
124-
int javaVersion
124+
int javaVersion,
125+
boolean isMainSourceSet
125126
) {
126127
SourceSet sourceSet = javaExtension.getSourceSets().maybeCreate(sourceSetName);
127128
for (String parentSourceSetName : parentSourceSets) {
@@ -135,6 +136,13 @@ private SourceSet addSourceSet(
135136
CompileOptions compileOptions = compileTask.getOptions();
136137
compileOptions.getRelease().set(javaVersion);
137138
});
139+
if (isMainSourceSet) {
140+
project.getTasks().create(sourceSet.getJavadocTaskName(), Javadoc.class, javadocTask -> {
141+
javadocTask.getJavadocTool().set(javaToolchains.javadocToolFor(spec -> {
142+
spec.getLanguageVersion().set(JavaLanguageVersion.of(javaVersion));
143+
}));
144+
});
145+
}
138146
configurePreviewFeatures(project, sourceSet, javaVersion);
139147

140148
// Since we configure MRJAR sourcesets to allow preview apis, class signatures for those

distribution/src/config/jvm.options

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
## should create one or more files in the jvm.options.d
1010
## directory containing your adjustments.
1111
##
12-
## See https://www.elastic.co/guide/en/elasticsearch/reference/@project.minor.version@/jvm-options.html
12+
## See https://www.elastic.co/guide/en/elasticsearch/reference/@project.minor.version@/advanced-configuration.html#set-jvm-options
1313
## for more information.
1414
##
1515
################################################################

docs/changelog/118585.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
pr: 118585
2+
summary: Add a generic `rescorer` retriever based on the search request's rescore
3+
functionality
4+
area: Ranking
5+
type: feature
6+
issues:
7+
- 118327
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
pr: 116944
1+
pr: 118825
22
summary: "Remove support for type, fields, `copy_to` and boost in metadata field definition"
33
area: Mapping
44
type: breaking
55
issues: []
66
breaking:
77
title: "Remove support for type, fields, copy_to and boost in metadata field definition"
88
area: Mapping
9-
details: The type, fields, copy_to and boost parameters are no longer supported in metadata field definition
9+
details: The type, fields, copy_to and boost parameters are no longer supported in metadata field definition starting with version 9.
1010
impact: Users providing type, fields, copy_to or boost as part of metadata field definition should remove them from their mappings.
1111
notable: false

docs/changelog/119007.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
pr: 119007
2+
summary: Block-writes cannot be added after read-only
3+
area: Data streams
4+
type: bug
5+
issues:
6+
- 119002

docs/reference/search/retriever.asciidoc

Lines changed: 120 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ A <<standard-retriever, retriever>> that replaces the functionality of a traditi
2222
`knn`::
2323
A <<knn-retriever, retriever>> that replaces the functionality of a <<search-api-knn, knn search>>.
2424

25+
`rescorer`::
26+
A <<rescorer-retriever, retriever>> that replaces the functionality of the <<rescore, query rescorer>>.
27+
2528
`rrf`::
2629
A <<rrf-retriever, retriever>> that produces top documents from <<rrf, reciprocal rank fusion (RRF)>>.
2730

@@ -371,6 +374,122 @@ GET movies/_search
371374
----
372375
// TEST[skip:uses ELSER]
373376

377+
[[rescorer-retriever]]
378+
==== Rescorer Retriever
379+
380+
The `rescorer` retriever re-scores only the results produced by its child retriever.
381+
For the `standard` and `knn` retrievers, the `window_size` parameter specifies the number of documents examined per shard.
382+
383+
For compound retrievers like `rrf`, the `window_size` parameter defines the total number of documents examined globally.
384+
385+
When using the `rescorer`, an error is returned if the following conditions are not met:
386+
387+
* The minimum configured rescore's `window_size` is:
388+
** Greater than or equal to the `size` of the parent retriever for nested `rescorer` setups.
389+
** Greater than or equal to the `size` of the search request when used as the primary retriever in the tree.
390+
391+
* And the maximum rescore's `window_size` is:
392+
** Smaller than or equal to the `size` or `rank_window_size` of the child retriever.
393+
394+
[discrete]
395+
[[rescorer-retriever-parameters]]
396+
===== Parameters
397+
398+
`rescore`::
399+
(Required. <<rescore, A rescorer definition or an array of rescorer definitions>>)
400+
+
401+
Defines the <<rescore, rescorers>> applied sequentially to the top documents returned by the child retriever.
402+
403+
`retriever`::
404+
(Required. <<retriever, retriever>>)
405+
+
406+
Specifies the child retriever responsible for generating the initial set of top documents to be re-ranked.
407+
408+
`filter`::
409+
(Optional. <<query-dsl, query object or list of query objects>>)
410+
+
411+
Applies a <<query-dsl-bool-query, boolean query filter>> to the retriever, ensuring that all documents match the filter criteria without affecting their scores.
412+
413+
[discrete]
414+
[[rescorer-retriever-example]]
415+
==== Example
416+
417+
The `rescorer` retriever can be placed at any level within the retriever tree.
418+
The following example demonstrates a `rescorer` applied to the results produced by an `rrf` retriever:
419+
420+
[source,console]
421+
----
422+
GET movies/_search
423+
{
424+
"size": 10, <1>
425+
"retriever": {
426+
"rescorer": { <2>
427+
"rescore": {
428+
"query": { <3>
429+
"window_size": 50, <4>
430+
"rescore_query": {
431+
"script_score": {
432+
"script": {
433+
"source": "cosineSimilarity(params.queryVector, 'product-vector_final_stage') + 1.0",
434+
"params": {
435+
"queryVector": [-0.5, 90.0, -10, 14.8, -156.0]
436+
}
437+
}
438+
}
439+
}
440+
}
441+
},
442+
"retriever": { <5>
443+
"rrf": {
444+
"rank_window_size": 100, <6>
445+
"retrievers": [
446+
{
447+
"standard": {
448+
"query": {
449+
"sparse_vector": {
450+
"field": "plot_embedding",
451+
"inference_id": "my-elser-model",
452+
"query": "films that explore psychological depths"
453+
}
454+
}
455+
}
456+
},
457+
{
458+
"standard": {
459+
"query": {
460+
"multi_match": {
461+
"query": "crime",
462+
"fields": [
463+
"plot",
464+
"title"
465+
]
466+
}
467+
}
468+
}
469+
},
470+
{
471+
"knn": {
472+
"field": "vector",
473+
"query_vector": [10, 22, 77],
474+
"k": 10,
475+
"num_candidates": 10
476+
}
477+
}
478+
]
479+
}
480+
}
481+
}
482+
}
483+
}
484+
----
485+
// TEST[skip:uses ELSER]
486+
<1> Specifies the number of top documents to return in the final response.
487+
<2> A `rescorer` retriever applied as the final step.
488+
<3> The definition of the `query` rescorer.
489+
<4> Defines the number of documents to rescore from the child retriever.
490+
<5> Specifies the child retriever definition.
491+
<6> Defines the number of documents returned by the `rrf` retriever, which limits the available documents to
492+
374493
[[text-similarity-reranker-retriever]]
375494
==== Text Similarity Re-ranker Retriever
376495

@@ -777,4 +896,4 @@ When a retriever is specified as part of a search, the following elements are no
777896
* <<search-after, `search_after`>>
778897
* <<request-body-search-terminate-after, `terminate_after`>>
779898
* <<search-sort-param, `sort`>>
780-
* <<rescore, `rescore`>>
899+
* <<rescore, `rescore`>> use a <<rescorer-retriever, rescorer retriever>> instead

libs/entitlement/bridge/src/main/java/org/elasticsearch/entitlement/bridge/EntitlementChecker.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
import java.net.URL;
1313
import java.net.URLStreamHandlerFactory;
14+
import java.util.List;
1415

1516
public interface EntitlementChecker {
1617

@@ -29,4 +30,10 @@ public interface EntitlementChecker {
2930
void check$java_net_URLClassLoader$(Class<?> callerClass, String name, URL[] urls, ClassLoader parent);
3031

3132
void check$java_net_URLClassLoader$(Class<?> callerClass, String name, URL[] urls, ClassLoader parent, URLStreamHandlerFactory factory);
33+
34+
// Process creation
35+
void check$$start(Class<?> callerClass, ProcessBuilder that, ProcessBuilder.Redirect[] redirects);
36+
37+
void check$java_lang_ProcessBuilder$startPipeline(Class<?> callerClass, List<ProcessBuilder> builders);
38+
3239
}

0 commit comments

Comments
 (0)