Skip to content

Commit c482469

Browse files
Merge branch '9.1' into backport-91-fix-125236
2 parents 13a4006 + bf735f4 commit c482469

File tree

51 files changed

+736
-38
lines changed

Some content is hidden

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

51 files changed

+736
-38
lines changed

.buildkite/hooks/pre-command

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,14 @@ if [[ "${USE_LUCENE_SNAPSHOT_CREDS:-}" == "true" ]]; then
6464
unset data
6565
fi
6666

67+
if [[ "${USE_MAVEN_GPG:-}" == "true" ]]; then
68+
vault_path="kv/ci-shared/release-eng/team-release-secrets/es-delivery/gpg"
69+
ORG_GRADLE_PROJECT_signingKey=$(vault kv get --field="private_key" $vault_path)
70+
ORG_GRADLE_PROJECT_signingPassword=$(vault kv get --field="passphase" $vault_path)
71+
export ORG_GRADLE_PROJECT_signingKey
72+
export ORG_GRADLE_PROJECT_signingPassword
73+
fi
74+
6775
if [[ "${USE_DRA_CREDENTIALS:-}" == "true" ]]; then
6876
DRA_VAULT_ROLE_ID_SECRET=$(vault read -field=role-id secret/ci/elastic-elasticsearch/legacy-vault-credentials)
6977
export DRA_VAULT_ROLE_ID_SECRET

.buildkite/pipelines/dra-workflow.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ steps:
22
- command: .buildkite/scripts/dra-workflow.sh
33
env:
44
USE_DRA_CREDENTIALS: "true"
5+
USE_MAVEN_GPG: "true"
56
USE_PROD_DOCKER_CREDENTIALS: "true"
67
agents:
78
provider: gcp

.buildkite/scripts/run-bc-upgrade-tests.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ select(.active_release == true) |
2424
(.build_candidates | to_entries | sort_by(.value.completed_at))) |
2525
last | .value.manifest_url")"
2626

27-
if [[ -z "$MANIFEST_URL" ]]; then
27+
if [[ -z "$MANIFEST_URL" ]] || [[ "$MANIFEST_URL" == "null" ]]; then
2828
echo "No snapshots or build candidates for branch [$BUILDKITE_BRANCH]."
2929
echo "Skipping BC upgrade tests."
3030
exit 0

.buildkite/scripts/run-pr-upgrade-tests.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ fi
1818

1919
# Identify the merge base of the current commit (branch) and the base branch of the pull request.
2020
# PR upgrade tests are run from the merge base to the current commit.
21-
BASE_COMMIT=$(git merge-base $BUILDKITE_PULL_REQUEST_BASE_BRANCH $BUILDKITE_COMMIT)
21+
git fetch origin $BUILDKITE_PULL_REQUEST_BASE_BRANCH
22+
BASE_COMMIT=$(git merge-base origin/$BUILDKITE_PULL_REQUEST_BASE_BRANCH $BUILDKITE_COMMIT)
2223

2324
VERSION=$(sed -n 's/^elasticsearch[[:space:]]*=[[:space:]]*\(.*\)/\1/p' build-tools-internal/version.properties)
2425

build-conventions/src/main/java/org/elasticsearch/gradle/internal/conventions/PublishPlugin.java

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,11 @@
1010
package org.elasticsearch.gradle.internal.conventions;
1111

1212
import groovy.util.Node;
13+
import nmcp.NmcpPlugin;
1314

1415
import com.github.jengelman.gradle.plugins.shadow.ShadowExtension;
1516
import com.github.jengelman.gradle.plugins.shadow.ShadowPlugin;
1617

17-
import nmcp.NmcpPlugin;
18-
1918
import org.elasticsearch.gradle.internal.conventions.info.GitInfo;
2019
import org.elasticsearch.gradle.internal.conventions.precommit.PomValidationPrecommitPlugin;
2120
import org.elasticsearch.gradle.internal.conventions.util.Util;
@@ -41,6 +40,8 @@
4140
import org.gradle.api.tasks.bundling.Jar;
4241
import org.gradle.initialization.layout.BuildLayout;
4342
import org.gradle.language.base.plugins.LifecycleBasePlugin;
43+
import org.gradle.plugins.signing.SigningExtension;
44+
import org.gradle.plugins.signing.SigningPlugin;
4445
import org.w3c.dom.Element;
4546

4647
import java.io.File;
@@ -69,6 +70,7 @@ public void apply(Project project) {
6970
project.getPluginManager().apply(PomValidationPrecommitPlugin.class);
7071
project.getPluginManager().apply(LicensingPlugin.class);
7172
project.getPluginManager().apply(NmcpPlugin.class);
73+
project.getPluginManager().apply(SigningPlugin.class);
7274
configureJavadocJar(project);
7375
configureSourcesJar(project);
7476
configurePomGeneration(project);
@@ -79,6 +81,13 @@ public void apply(Project project) {
7981
private void configurePublications(Project project) {
8082
var publishingExtension = project.getExtensions().getByType(PublishingExtension.class);
8183
var publication = publishingExtension.getPublications().create("elastic", MavenPublication.class);
84+
Provider<String> signingKey = project.getProviders().gradleProperty("signingKey");
85+
if (signingKey.isPresent()) {
86+
SigningExtension signing = project.getExtensions().getByType(SigningExtension.class);
87+
signing.useInMemoryPgpKeys(signingKey.get(), project.getProviders().gradleProperty("signingPassword").get());
88+
signing.sign(publication);
89+
}
90+
8291
project.afterEvaluate(project1 -> {
8392
if (project1.getPlugins().hasPlugin(ShadowPlugin.class)) {
8493
configureWithShadowPlugin(project1, publication);

build-tools-internal/src/main/resources/checkstyle_suppressions.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
<suppress files="qa[/\\]rolling-upgrade[/\\]src[/\\]javaRestTest[/\\]java[/\\]org[/\\]elasticsearch[/\\]upgrades[/\\]TsdbIT.java" checks="LineLength" />
3838
<suppress files="qa[/\\]rolling-upgrade[/\\]src[/\\]javaRestTest[/\\]java[/\\]org[/\\]elasticsearch[/\\]upgrades[/\\]TsdbIndexingRollingUpgradeIT.java" checks="LineLength" />
3939
<suppress files="qa[/\\]rolling-upgrade[/\\]src[/\\]javaRestTest[/\\]java[/\\]org[/\\]elasticsearch[/\\]upgrades[/\\]LogsdbIndexingRollingUpgradeIT.java" checks="LineLength" />
40+
<suppress files="plugin[/\\]logsdb[/\\]qa[/\\]rolling-upgrade[/\\]src[/\\]javaRestTest[/\\]java[/\\]org[/\\]elasticsearch[/\\]upgrades[/\\]MatchOnlyTextRollingUpgradeIT.java" checks="LineLength" />
4041

4142
<!-- Gradle requires inputs to be seriablizable -->
4243
<suppress files="build-tools-internal[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]gradle[/\\]internal[/\\]precommit[/\\]TestingConventionRule.java" checks="RegexpSinglelineJava" />

docs/changelog/130221.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
pr: 130221
2+
summary: Fix incorrect accounting of semantic text indexing memory pressure
3+
area: Distributed
4+
type: bug
5+
issues: []

docs/reference/query-languages/query-dsl/query-dsl-knn-query.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,36 @@ A sample query can look like below:
229229

230230
Note that nested `knn` only supports `score_mode=max`.
231231

232+
## Knn query on a semantic_text field [knn-query-with-semantic-text]
233+
234+
Elasticsearch supports knn queries over a [
235+
`semantic_text` field](/reference/elasticsearch/mapping-reference/semantic-text.md).
236+
237+
Here is an example using the `query_vector_builder`:
238+
239+
```json
240+
{
241+
"query": {
242+
"knn": {
243+
"field": "inference_field",
244+
"k": 10,
245+
"num_candidates": 100,
246+
"query_vector_builder": {
247+
"text_embedding": {
248+
"model_text": "test"
249+
}
250+
}
251+
}
252+
}
253+
}
254+
```
255+
256+
Note that for `semantic_text` fields, the `model_id` does not have to be
257+
provided as it can be inferred from the `semantic_text` field mapping.
258+
259+
Knn search using query vectors over `semantic_text` fields is also supported,
260+
with no change to the API.
261+
232262
## Knn query with aggregations [knn-query-aggregations]
233263

234264
`knn` query calculates aggregations on top `k` documents from each shard. Thus, the final results from aggregations contain `k * number_of_shards` documents. This is different from the [top level knn section](docs-content://solutions/search/vector/knn.md) where aggregations are calculated on the global top `k` nearest documents.

libs/entitlement/src/main/java/org/elasticsearch/entitlement/bootstrap/EntitlementBootstrap.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ static void loadAgent(String agentPath, String entitlementInitializationClassNam
122122
vm.detach();
123123
}
124124
} catch (AttachNotSupportedException | IOException | AgentLoadException | AgentInitializationException e) {
125-
throw new IllegalStateException("Unable to attach entitlement agent", e);
125+
throw new IllegalStateException("Unable to attach entitlement agent [" + agentPath + "]", e);
126126
}
127127
}
128128

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

Lines changed: 41 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -362,10 +362,38 @@ public Query phrasePrefixQuery(TokenStream stream, int slop, int maxExpansions,
362362
return toQuery(query, queryShardContext);
363363
}
364364

365+
private static class BytesFromMixedStringsBytesRefBlockLoader extends BlockStoredFieldsReader.StoredFieldsBlockLoader {
366+
BytesFromMixedStringsBytesRefBlockLoader(String field) {
367+
super(field);
368+
}
369+
370+
@Override
371+
public Builder builder(BlockFactory factory, int expectedCount) {
372+
return factory.bytesRefs(expectedCount);
373+
}
374+
375+
@Override
376+
public RowStrideReader rowStrideReader(LeafReaderContext context) throws IOException {
377+
return new BlockStoredFieldsReader.Bytes(field) {
378+
private final BytesRef scratch = new BytesRef();
379+
380+
@Override
381+
protected BytesRef toBytesRef(Object v) {
382+
if (v instanceof BytesRef b) {
383+
return b;
384+
} else {
385+
assert v instanceof String;
386+
return BlockSourceReader.toBytesRef(scratch, v.toString());
387+
}
388+
}
389+
};
390+
}
391+
}
392+
365393
@Override
366394
public BlockLoader blockLoader(BlockLoaderContext blContext) {
367395
if (textFieldType.isSyntheticSource()) {
368-
return new BlockStoredFieldsReader.BytesFromBytesRefsBlockLoader(storedFieldNameForSyntheticSource());
396+
return new BytesFromMixedStringsBytesRefBlockLoader(storedFieldNameForSyntheticSource());
369397
}
370398
SourceValueFetcher fetcher = SourceValueFetcher.toString(blContext.sourcePaths(name()));
371399
// MatchOnlyText never has norms, so we have to use the field names field
@@ -386,7 +414,12 @@ public IndexFieldData.Builder fielddataBuilder(FieldDataContext fieldDataContext
386414
) {
387415
@Override
388416
protected BytesRef storedToBytesRef(Object stored) {
389-
return (BytesRef) stored;
417+
if (stored instanceof BytesRef storedBytes) {
418+
return storedBytes;
419+
} else {
420+
assert stored instanceof String;
421+
return new BytesRef(stored.toString());
422+
}
390423
}
391424
};
392425
}
@@ -477,7 +510,12 @@ protected SyntheticSourceSupport syntheticSourceSupport() {
477510
() -> new StringStoredFieldFieldLoader(fieldType().storedFieldNameForSyntheticSource(), fieldType().name(), leafName()) {
478511
@Override
479512
protected void write(XContentBuilder b, Object value) throws IOException {
480-
b.value(((BytesRef) value).utf8ToString());
513+
if (value instanceof BytesRef valueBytes) {
514+
b.value(valueBytes.utf8ToString());
515+
} else {
516+
assert value instanceof String;
517+
b.value(value.toString());
518+
}
481519
}
482520
}
483521
);

0 commit comments

Comments
 (0)