Skip to content

Commit

Permalink
Merge branch 'main' into esql_full_text_ser
Browse files Browse the repository at this point in the history
  • Loading branch information
elasticmachine authored Jun 18, 2024
2 parents 2c49a2c + a3f4d51 commit 81a1d01
Show file tree
Hide file tree
Showing 17 changed files with 686 additions and 92 deletions.
6 changes: 6 additions & 0 deletions docs/changelog/109824.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
pr: 109824
summary: Check array size before returning array item in script doc values
area: Infra/Scripting
type: bug
issues:
- 104998
15 changes: 12 additions & 3 deletions muted-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ tests:
method: "testGuessIsDayFirstFromLocale"
- class: "org.elasticsearch.test.rest.ClientYamlTestSuiteIT"
issue: "https://github.com/elastic/elasticsearch/issues/108857"
method: "test {yaml=search/180_locale_dependent_mapping/Test Index and Search locale dependent mappings / dates}"
method: "test {yaml=search/180_locale_dependent_mapping/Test Index and Search locale\
\ dependent mappings / dates}"
- class: "org.elasticsearch.upgrades.SearchStatesIT"
issue: "https://github.com/elastic/elasticsearch/issues/108991"
method: "testCanMatch"
Expand All @@ -19,7 +20,8 @@ tests:
method: "testTrainedModelInference"
- class: "org.elasticsearch.xpack.security.CoreWithSecurityClientYamlTestSuiteIT"
issue: "https://github.com/elastic/elasticsearch/issues/109188"
method: "test {yaml=search/180_locale_dependent_mapping/Test Index and Search locale dependent mappings / dates}"
method: "test {yaml=search/180_locale_dependent_mapping/Test Index and Search locale\
\ dependent mappings / dates}"
- class: "org.elasticsearch.xpack.esql.qa.mixed.EsqlClientYamlIT"
issue: "https://github.com/elastic/elasticsearch/issues/109189"
method: "test {p0=esql/70_locale/Date format with Italian locale}"
Expand All @@ -34,7 +36,8 @@ tests:
method: "testTimestampFieldTypeExposedByAllIndicesServices"
- class: "org.elasticsearch.analysis.common.CommonAnalysisClientYamlTestSuiteIT"
issue: "https://github.com/elastic/elasticsearch/issues/109318"
method: "test {yaml=analysis-common/50_char_filters/pattern_replace error handling (too complex pattern)}"
method: "test {yaml=analysis-common/50_char_filters/pattern_replace error handling\
\ (too complex pattern)}"
- class: "org.elasticsearch.xpack.ml.integration.ClassificationHousePricingIT"
issue: "https://github.com/elastic/elasticsearch/issues/101598"
method: "testFeatureImportanceValues"
Expand All @@ -61,6 +64,12 @@ tests:
- class: org.elasticsearch.action.search.SearchProgressActionListenerIT
method: testSearchProgressWithHits
issue: https://github.com/elastic/elasticsearch/issues/109830
- class: "org.elasticsearch.xpack.shutdown.NodeShutdownReadinessIT"
issue: "https://github.com/elastic/elasticsearch/issues/109838"
method: "testShutdownReadinessService"
- class: "org.elasticsearch.packaging.test.PackageTests"
issue: "https://github.com/elastic/elasticsearch/issues/109841"
method: "test50Remove"

# Examples:
#
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -863,18 +863,22 @@ nested object:
- '{ "create": { } }'
- '{ "name": "aaaa", "nested_field": {"a": 1, "b": 2}, "nested_array": [{ "a": 10, "b": 20 }, { "a": 100, "b": 200 }] }'

- match: { errors: false }

- do:
search:
index: test

- match: { hits.total.value: 1 }
- match: { hits.hits.0._source.name: aaaa }
- match: { hits.hits.0._source.nested_field.a: 1 }
- match: { hits.hits.0._source.nested_field.b: 2 }
- match: { hits.hits.0._source.nested_array.0.a: 10 }
- match: { hits.hits.0._source.nested_array.0.b: 20 }
- match: { hits.hits.0._source.nested_array.1.a: 100 }
- match: { hits.hits.0._source.nested_array.1.b: 200 }
- match: { hits.total.value: 1 }
- match: { hits.hits.0._source.name: aaaa }
- length: { hits.hits.0._source.nested_field: 2 }
- match: { hits.hits.0._source.nested_field.a: 1 }
- match: { hits.hits.0._source.nested_field.b: 2 }
- length: { hits.hits.0._source.nested_array: 2 }
- match: { hits.hits.0._source.nested_array.0.a: 10 }
- match: { hits.hits.0._source.nested_array.0.b: 20 }
- match: { hits.hits.0._source.nested_array.1.a: 100 }
- match: { hits.hits.0._source.nested_array.1.b: 200 }


---
Expand Down Expand Up @@ -906,15 +910,201 @@ nested object next to regular:
- '{ "create": { } }'
- '{ "name": "aaaa", "path": { "to": { "nested": [{ "a": 10, "b": 20 }, { "a": 100, "b": 200 } ], "regular": [{ "a": 10, "b": 20 }, { "a": 100, "b": 200 } ] } } }'

- match: { errors: false }

- do:
search:
index: test

- match: { hits.total.value: 1 }
- match: { hits.hits.0._source.name: aaaa }
- match: { hits.hits.0._source.path.to.nested.0.a: 10 }
- match: { hits.hits.0._source.path.to.nested.0.b: 20 }
- match: { hits.hits.0._source.path.to.nested.1.a: 100 }
- match: { hits.hits.0._source.path.to.nested.1.b: 200 }
- match: { hits.hits.0._source.path.to.regular.a: [ 10, 100 ] }
- match: { hits.hits.0._source.path.to.regular.b: [ 20, 200 ] }
- match: { hits.total.value: 1 }
- match: { hits.hits.0._source.name: aaaa }
- length: { hits.hits.0._source.path.to.nested: 2 }
- match: { hits.hits.0._source.path.to.nested.0.a: 10 }
- match: { hits.hits.0._source.path.to.nested.0.b: 20 }
- match: { hits.hits.0._source.path.to.nested.1.a: 100 }
- match: { hits.hits.0._source.path.to.nested.1.b: 200 }
- match: { hits.hits.0._source.path.to.regular.a: [ 10, 100 ] }
- match: { hits.hits.0._source.path.to.regular.b: [ 20, 200 ] }


---
nested object with disabled:
- requires:
cluster_features: ["mapper.track_ignored_source"]
reason: requires tracking ignored source

- do:
indices.create:
index: test
body:
mappings:
_source:
mode: synthetic
properties:
obj_field:
properties:
obj1:
enabled: false
sub_nested:
type: nested
nested_field:
type: nested
properties:
obj1:
enabled: false
nested_array:
type: nested
properties:
obj1:
enabled: false

- do:
bulk:
index: test
refresh: true
body:
- '{ "create": { } }'
- '{ "id": 0, "nested_field": {"a": 1, "b": 2, "obj1": { "foo": "bar", "k": [1, 2, 3]}}, "nested_array": [{ "a": 10, "b": 20, "obj1": [{"field1": 1, "field2": 2}, {"field3": 3, "field4": 4}]}, { "a": 100, "b": 200, "obj1": {"field5": 5, "field6": 6}}]}'
- '{ "create": { } }'
- '{ "id": 1, "obj_field": {"a": 1, "b": 2, "obj1": { "foo": "bar", "k": [1, 2, 3]}, "sub_nested": [{ "a": 10, "b": 20}, { "a": 100, "b": 200}]}}'

- match: { errors: false }

- do:
search:
index: test
sort: "id"

- match: { hits.total.value: 2 }
- length: { hits.hits.0._source: 3 }
- match: { hits.hits.0._source.id: 0 }
- length: { hits.hits.0._source.nested_field: 3 }
- match: { hits.hits.0._source.nested_field.a: 1 }
- match: { hits.hits.0._source.nested_field.b: 2 }
- length: { hits.hits.0._source.nested_field.obj1: 2 }
- match: { hits.hits.0._source.nested_field.obj1.foo: "bar" }
- match: { hits.hits.0._source.nested_field.obj1.k: [1, 2, 3] }
- length: { hits.hits.0._source.nested_array: 2 }
- match: { hits.hits.0._source.nested_array.0.a: 10 }
- match: { hits.hits.0._source.nested_array.0.b: 20 }
- length: { hits.hits.0._source.nested_array.0.obj1: 2 }
- match: { hits.hits.0._source.nested_array.0.obj1.0.field1: 1 }
- match: { hits.hits.0._source.nested_array.0.obj1.0.field2: 2 }
- match: { hits.hits.0._source.nested_array.0.obj1.1.field3: 3 }
- match: { hits.hits.0._source.nested_array.0.obj1.1.field4: 4 }
- length: { hits.hits.0._source.nested_array.1: 3 }
- match: { hits.hits.0._source.nested_array.1.a: 100 }
- match: { hits.hits.0._source.nested_array.1.b: 200 }
- length: { hits.hits.0._source.nested_array.1.obj1: 2 }
- match: { hits.hits.0._source.nested_array.1.obj1.field5: 5 }
- match: { hits.hits.0._source.nested_array.1.obj1.field6: 6 }
- length: { hits.hits.1._source: 2 }
- match: { hits.hits.1._source.id: 1 }
- length: { hits.hits.1._source.obj_field: 4 }
- match: { hits.hits.1._source.obj_field.a: 1 }
- match: { hits.hits.1._source.obj_field.b: 2 }
- length: { hits.hits.1._source.obj_field.obj1: 2 }
- match: { hits.hits.1._source.obj_field.obj1.foo: "bar" }
- match: { hits.hits.1._source.obj_field.obj1.k: [ 1, 2, 3 ] }
- length: { hits.hits.1._source.obj_field.sub_nested: 2 }
- length: { hits.hits.1._source.obj_field.sub_nested.0: 2 }
- match: { hits.hits.1._source.obj_field.sub_nested.0.a: 10 }
- match: { hits.hits.1._source.obj_field.sub_nested.0.b: 20 }
- length: { hits.hits.1._source.obj_field.sub_nested.1: 2 }
- match: { hits.hits.1._source.obj_field.sub_nested.1.a: 100 }
- match: { hits.hits.1._source.obj_field.sub_nested.1.b: 200 }


---
doubly nested object:
- requires:
cluster_features: ["mapper.track_ignored_source"]
reason: requires tracking ignored source

- do:
indices.create:
index: test
body:
mappings:
_source:
mode: synthetic
properties:
obj_field:
properties:
obj1:
enabled: false
sub_nested:
type: nested
nested_field:
type: nested
properties:
sub_nested_field:
type: nested
properties:
obj1:
enabled: false

- do:
bulk:
index: test
refresh: true
body:
- '{ "create": { } }'
- '{ "id": 0, "nested_field": {"a": 1, "b": 2, "sub_nested_field": {"foo": "bar", "k": [1, 2, 3]}}}'
- '{ "create": { } }'
- '{ "id": 1, "nested_field": {"a": 2, "b": 3, "sub_nested_field": [{"foo": "baz", "k": [4, 50, 6]}, {"foo": "bar"}]}}'
- '{ "create": { } }'
- '{ "id": 2, "nested_field": [{"a": 20, "b": 30, "sub_nested_field": [{"foo": "foobar", "k": [7, 8, 9]}, {"k": [400, 500, 6]}]}, {"a": 0, "b": 33, "sub_nested_field": [{"other": "value", "k": [1, 2, -3]}, {"number": 42}]}]}'
- '{ "create": { } }'
- '{ "id": 3}'

- match: { errors: false }

- do:
search:
index: test
sort: "id"

- match: { hits.total.value: 4 }
- length: { hits.hits.0._source: 2 }
- match: { hits.hits.0._source.id: 0 }
- length: { hits.hits.0._source.nested_field: 3 }
- match: { hits.hits.0._source.nested_field.a: 1 }
- match: { hits.hits.0._source.nested_field.b: 2 }
- length: { hits.hits.0._source.nested_field.sub_nested_field: 2 }
- match: { hits.hits.0._source.nested_field.sub_nested_field.foo: "bar" }
- match: { hits.hits.0._source.nested_field.sub_nested_field.k: [ 1, 2, 3 ] }
- length: { hits.hits.1._source: 2 }
- match: { hits.hits.1._source.id: 1 }
- length: { hits.hits.1._source.nested_field: 3 }
- match: { hits.hits.1._source.nested_field.a: 2 }
- match: { hits.hits.1._source.nested_field.b: 3 }
- length: { hits.hits.1._source.nested_field.sub_nested_field: 2 }
- length: { hits.hits.1._source.nested_field.sub_nested_field.0: 2 }
- match: { hits.hits.1._source.nested_field.sub_nested_field.0.foo: "baz" }
- match: { hits.hits.1._source.nested_field.sub_nested_field.0.k: [ 4, 6, 50 ] }
- length: { hits.hits.1._source.nested_field.sub_nested_field.1: 1 }
- match: { hits.hits.1._source.nested_field.sub_nested_field.1.foo: "bar" }
- length: { hits.hits.2._source: 2 }
- match: { hits.hits.2._source.id: 2 }
- length: { hits.hits.2._source.nested_field: 2 }
- length: { hits.hits.2._source.nested_field.0: 3 }
- match: { hits.hits.2._source.nested_field.0.a: 20 }
- match: { hits.hits.2._source.nested_field.0.b: 30 }
- length: { hits.hits.2._source.nested_field.0.sub_nested_field: 2 }
- length: { hits.hits.2._source.nested_field.0.sub_nested_field.0: 2 }
- match: { hits.hits.2._source.nested_field.0.sub_nested_field.0.foo: "foobar" }
- match: { hits.hits.2._source.nested_field.0.sub_nested_field.0.k: [ 7, 8, 9 ] }
- length: { hits.hits.2._source.nested_field.0.sub_nested_field.1: 1 }
- match: { hits.hits.2._source.nested_field.0.sub_nested_field.1.k: [6, 400, 500] }
- length: { hits.hits.2._source.nested_field.1: 3 }
- match: { hits.hits.2._source.nested_field.1.a: 0 }
- match: { hits.hits.2._source.nested_field.1.b: 33 }
- length: { hits.hits.2._source.nested_field.1.sub_nested_field: 2 }
- length: { hits.hits.2._source.nested_field.1.sub_nested_field.0: 2 }
- match: { hits.hits.2._source.nested_field.1.sub_nested_field.0.other: "value" }
- match: { hits.hits.2._source.nested_field.1.sub_nested_field.0.k: [ -3, 1, 2 ] }
- length: { hits.hits.2._source.nested_field.1.sub_nested_field.1: 1 }
- match: { hits.hits.2._source.nested_field.1.sub_nested_field.1.number: 42 }
- length: { hits.hits.3._source: 1 }
- match: { hits.hits.3._source.id: 3 }
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
import org.elasticsearch.action.FailedNodeException;
import org.elasticsearch.cluster.ClusterName;
import org.elasticsearch.common.collect.Iterators;
import org.elasticsearch.common.xcontent.ChunkedToXContent;
import org.elasticsearch.common.xcontent.ChunkedToXContentHelper;
import org.elasticsearch.common.xcontent.ChunkedToXContentObject;
import org.elasticsearch.rest.action.RestActions;
import org.elasticsearch.xcontent.ToXContent;

Expand All @@ -21,7 +21,7 @@

public abstract class BaseNodesXContentResponse<TNodeResponse extends BaseNodeResponse> extends BaseNodesResponse<TNodeResponse>
implements
ChunkedToXContent {
ChunkedToXContentObject {

protected BaseNodesXContentResponse(ClusterName clusterName, List<TNodeResponse> nodes, List<FailedNodeException> failures) {
super(clusterName, nodes, failures);
Expand Down
Loading

0 comments on commit 81a1d01

Please sign in to comment.