Skip to content

Commit 11eb1c6

Browse files
authored
Merge branch 'main' into esql-dls-opt-in-ccs-test
2 parents 11c6be9 + 5e467bf commit 11eb1c6

File tree

115 files changed

+1194
-785
lines changed

Some content is hidden

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

115 files changed

+1194
-785
lines changed

benchmarks/src/main/java/org/elasticsearch/benchmark/search/fetch/subphase/FetchSourcePhaseBenchmark.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public void setup() throws IOException {
6363
);
6464
includesSet = Set.of(fetchContext.includes());
6565
excludesSet = Set.of(fetchContext.excludes());
66-
parserConfig = XContentParserConfiguration.EMPTY.withFiltering(includesSet, excludesSet, false);
66+
parserConfig = XContentParserConfiguration.EMPTY.withFiltering(null, includesSet, excludesSet, false);
6767
}
6868

6969
private BytesReference read300BytesExample() throws IOException {

benchmarks/src/main/java/org/elasticsearch/benchmark/xcontent/FilterContentBenchmark.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ private XContentParserConfiguration buildParseConfig(boolean matchDotsInFieldNam
170170
includes = null;
171171
excludes = filters;
172172
}
173-
return XContentParserConfiguration.EMPTY.withFiltering(includes, excludes, matchDotsInFieldNames);
173+
return XContentParserConfiguration.EMPTY.withFiltering(null, includes, excludes, matchDotsInFieldNames);
174174
}
175175

176176
private BytesReference filter(XContentParserConfiguration contentParserConfiguration) throws IOException {

docs/changelog/113827.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
pr: 113827
2+
summary: Add Optional Source Filtering to Source Loaders
3+
area: Mapping
4+
type: enhancement
5+
issues: []

docs/changelog/117939.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
pr: 117939
2+
summary: Adding default endpoint for Elastic Rerank
3+
area: Machine Learning
4+
type: enhancement
5+
issues: []

docs/changelog/118370.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
pr: 118370
2+
summary: Fix concurrency issue with `ReinitializingSourceProvider`
3+
area: Mapping
4+
type: bug
5+
issues:
6+
- 118238

docs/changelog/118380.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
pr: 118380
2+
summary: Restore original "is within leaf" value in `SparseVectorFieldMapper`
3+
area: Mapping
4+
type: bug
5+
issues: []

docs/reference/tab-widgets/inference-api/infer-api-task.asciidoc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ the `cosine` measures are equivalent.
3636
------------------------------------------------------------
3737
PUT _inference/sparse_embedding/elser_embeddings <1>
3838
{
39-
"service": "elser",
39+
"service": "elasticsearch",
4040
"service_settings": {
4141
"num_allocations": 1,
4242
"num_threads": 1
@@ -206,7 +206,7 @@ PUT _inference/text_embedding/google_vertex_ai_embeddings <1>
206206
<2> A valid service account in JSON format for the Google Vertex AI API.
207207
<3> For the list of the available models, refer to the https://cloud.google.com/vertex-ai/generative-ai/docs/model-reference/text-embeddings-api[Text embeddings API] page.
208208
<4> The name of the location to use for the {infer} task. Refer to https://cloud.google.com/vertex-ai/generative-ai/docs/learn/locations[Generative AI on Vertex AI locations] for available locations.
209-
<5> The name of the project to use for the {infer} task.
209+
<5> The name of the project to use for the {infer} task.
210210

211211
// end::google-vertex-ai[]
212212

libs/x-content/impl/src/main/java/org/elasticsearch/xcontent/provider/XContentParserConfigurationImpl.java

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
import org.elasticsearch.xcontent.provider.filtering.FilterPathBasedFilter;
2020
import org.elasticsearch.xcontent.support.filtering.FilterPath;
2121

22+
import java.util.ArrayList;
23+
import java.util.List;
2224
import java.util.Set;
2325

2426
public class XContentParserConfigurationImpl implements XContentParserConfiguration {
@@ -106,12 +108,41 @@ public XContentParserConfiguration withFiltering(
106108
Set<String> excludeStrings,
107109
boolean filtersMatchFieldNamesWithDots
108110
) {
111+
return withFiltering(null, includeStrings, excludeStrings, filtersMatchFieldNamesWithDots);
112+
}
113+
114+
public XContentParserConfiguration withFiltering(
115+
String prefixPath,
116+
Set<String> includeStrings,
117+
Set<String> excludeStrings,
118+
boolean filtersMatchFieldNamesWithDots
119+
) {
120+
FilterPath[] includePaths = FilterPath.compile(includeStrings);
121+
FilterPath[] excludePaths = FilterPath.compile(excludeStrings);
122+
123+
if (prefixPath != null) {
124+
if (includePaths != null) {
125+
List<FilterPath> includeFilters = new ArrayList<>();
126+
for (var incl : includePaths) {
127+
incl.matches(prefixPath, includeFilters, true);
128+
}
129+
includePaths = includeFilters.isEmpty() ? null : includeFilters.toArray(FilterPath[]::new);
130+
}
131+
132+
if (excludePaths != null) {
133+
List<FilterPath> excludeFilters = new ArrayList<>();
134+
for (var excl : excludePaths) {
135+
excl.matches(prefixPath, excludeFilters, true);
136+
}
137+
excludePaths = excludeFilters.isEmpty() ? null : excludeFilters.toArray(FilterPath[]::new);
138+
}
139+
}
109140
return new XContentParserConfigurationImpl(
110141
registry,
111142
deprecationHandler,
112143
restApiVersion,
113-
FilterPath.compile(includeStrings),
114-
FilterPath.compile(excludeStrings),
144+
includePaths,
145+
excludePaths,
115146
filtersMatchFieldNamesWithDots
116147
);
117148
}

libs/x-content/src/main/java/org/elasticsearch/xcontent/XContentParserConfiguration.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,27 @@ public interface XContentParserConfiguration {
4949

5050
RestApiVersion restApiVersion();
5151

52+
// TODO: Remove when serverless uses the new API
53+
XContentParserConfiguration withFiltering(
54+
Set<String> includeStrings,
55+
Set<String> excludeStrings,
56+
boolean filtersMatchFieldNamesWithDots
57+
);
58+
5259
/**
5360
* Replace the configured filtering.
61+
*
62+
* @param prefixPath The path to be prepended to each sub-path before applying the include/exclude rules.
63+
* Specify {@code null} if parsing starts from the root.
64+
* @param includeStrings A set of strings representing paths to include during filtering.
65+
* If specified, only these paths will be included in parsing.
66+
* @param excludeStrings A set of strings representing paths to exclude during filtering.
67+
* If specified, these paths will be excluded from parsing.
68+
* @param filtersMatchFieldNamesWithDots Indicates whether filters should match field names containing dots ('.')
69+
* as part of the field name.
5470
*/
5571
XContentParserConfiguration withFiltering(
72+
String prefixPath,
5673
Set<String> includeStrings,
5774
Set<String> excludeStrings,
5875
boolean filtersMatchFieldNamesWithDots

libs/x-content/src/test/java/org/elasticsearch/xcontent/support/filtering/AbstractXContentFilteringTestCase.java

Lines changed: 38 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import java.io.IOException;
2323
import java.util.Arrays;
2424
import java.util.Collection;
25+
import java.util.HashSet;
2526
import java.util.Set;
2627
import java.util.stream.IntStream;
2728

@@ -332,6 +333,24 @@ protected final void testFilter(Builder expected, Builder sample, Collection<Str
332333
private void testFilter(Builder expected, Builder sample, Set<String> includes, Set<String> excludes, boolean matchFieldNamesWithDots)
333334
throws IOException {
334335
assertFilterResult(expected.apply(createBuilder()), filter(sample, includes, excludes, matchFieldNamesWithDots));
336+
337+
String rootPrefix = "root.path.random";
338+
if (includes != null) {
339+
Set<String> rootIncludes = new HashSet<>();
340+
for (var incl : includes) {
341+
rootIncludes.add(rootPrefix + (randomBoolean() ? "." : "*.") + incl);
342+
}
343+
includes = rootIncludes;
344+
}
345+
346+
if (excludes != null) {
347+
Set<String> rootExcludes = new HashSet<>();
348+
for (var excl : excludes) {
349+
rootExcludes.add(rootPrefix + (randomBoolean() ? "." : "*.") + excl);
350+
}
351+
excludes = rootExcludes;
352+
}
353+
assertFilterResult(expected.apply(createBuilder()), filterSub(sample, rootPrefix, includes, excludes, matchFieldNamesWithDots));
335354
}
336355

337356
public void testArrayWithEmptyObjectInInclude() throws IOException {
@@ -413,21 +432,36 @@ private XContentBuilder filter(Builder sample, Set<String> includes, Set<String>
413432
&& matchFieldNamesWithDots == false) {
414433
return filterOnBuilder(sample, includes, excludes);
415434
}
416-
return filterOnParser(sample, includes, excludes, matchFieldNamesWithDots);
435+
return filterOnParser(sample, null, includes, excludes, matchFieldNamesWithDots);
436+
}
437+
438+
private XContentBuilder filterSub(
439+
Builder sample,
440+
String root,
441+
Set<String> includes,
442+
Set<String> excludes,
443+
boolean matchFieldNamesWithDots
444+
) throws IOException {
445+
return filterOnParser(sample, root, includes, excludes, matchFieldNamesWithDots);
417446
}
418447

419448
private XContentBuilder filterOnBuilder(Builder sample, Set<String> includes, Set<String> excludes) throws IOException {
420449
return sample.apply(XContentBuilder.builder(getXContentType(), includes, excludes));
421450
}
422451

423-
private XContentBuilder filterOnParser(Builder sample, Set<String> includes, Set<String> excludes, boolean matchFieldNamesWithDots)
424-
throws IOException {
452+
private XContentBuilder filterOnParser(
453+
Builder sample,
454+
String rootPath,
455+
Set<String> includes,
456+
Set<String> excludes,
457+
boolean matchFieldNamesWithDots
458+
) throws IOException {
425459
try (XContentBuilder builtSample = sample.apply(createBuilder())) {
426460
BytesReference sampleBytes = BytesReference.bytes(builtSample);
427461
try (
428462
XContentParser parser = getXContentType().xContent()
429463
.createParser(
430-
XContentParserConfiguration.EMPTY.withFiltering(includes, excludes, matchFieldNamesWithDots),
464+
XContentParserConfiguration.EMPTY.withFiltering(rootPath, includes, excludes, matchFieldNamesWithDots),
431465
sampleBytes.streamInput()
432466
)
433467
) {

0 commit comments

Comments
 (0)