-
Notifications
You must be signed in to change notification settings - Fork 25k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Parse the contents of dynamic objects for [subobjects:false] #117762
Changes from 11 commits
493fbb2
5d70e77
8cb5a9f
04056fd
b269005
99f7931
8748d6c
d6895d8
f514ca0
a08c482
4b5590c
73638b9
de7c396
39c3b76
7c7ecfd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
pr: 117762 | ||
summary: "Parse the contents of dynamic objects for [subobjects:false]" | ||
area: Mapping | ||
type: bug | ||
issues: | ||
- 117544 |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1177,3 +1177,115 @@ fetch geo_point: | |
- is_false: hits.hits.0.fields.message | ||
- match: { hits.hits.0._source.message.foo: 10 } | ||
- match: { hits.hits.0._source.message.foo\.bar: 20 } | ||
|
||
--- | ||
root with subobjects false and dynamic false: | ||
- requires: | ||
cluster_features: mapper.fix_parsing_subobjects_false_dynamic_false | ||
reason: bug fix | ||
|
||
- do: | ||
indices.create: | ||
index: test | ||
body: | ||
mappings: | ||
subobjects: false | ||
dynamic: false | ||
properties: | ||
my.keyword.field: | ||
type: keyword | ||
|
||
- do: | ||
bulk: | ||
index: test | ||
refresh: true | ||
body: | ||
- '{ "index": { } }' | ||
- '{ "my": { "keyword.field": "abc" } }' | ||
- match: { errors: false } | ||
|
||
# indexing a dynamically-mapped field still fails (silently) | ||
- do: | ||
bulk: | ||
index: test | ||
refresh: true | ||
body: | ||
- '{ "index": { } }' | ||
- '{ "my": { "random.field": "abc" } }' | ||
- match: { errors: false } | ||
|
||
- do: | ||
search: | ||
index: test | ||
body: | ||
fields: [ "*" ] | ||
|
||
- match: { hits.hits.0.fields: { my.keyword.field: [ abc ] } } | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You'll need to sort results for this test to work with multiple shards. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Keep forgetting that.. Done. |
||
- match: { hits.hits.1.fields: null } | ||
|
||
- do: | ||
search: | ||
index: test | ||
body: | ||
query: | ||
match: | ||
my.keyword.field: abc | ||
|
||
- match: { hits.total.value: 1 } | ||
|
||
--- | ||
object with subobjects false and dynamic false: | ||
- requires: | ||
cluster_features: mapper.fix_parsing_subobjects_false_dynamic_false | ||
reason: bug fix | ||
|
||
- do: | ||
indices.create: | ||
index: test | ||
body: | ||
mappings: | ||
properties: | ||
my: | ||
subobjects: false | ||
dynamic: false | ||
properties: | ||
nested.keyword.field: | ||
type: keyword | ||
|
||
- do: | ||
bulk: | ||
index: test | ||
refresh: true | ||
body: | ||
- '{ "index": { } }' | ||
- '{ "my": { "nested": { "keyword.field": "abc" } } }' | ||
- match: { errors: false } | ||
|
||
# indexing a dynamically-mapped field still fails (silently) | ||
- do: | ||
bulk: | ||
index: test | ||
refresh: true | ||
body: | ||
- '{ "index": { } }' | ||
- '{ "my": { "nested": { "random.field": "abc" } } }' | ||
- match: { errors: false } | ||
|
||
- do: | ||
search: | ||
index: test | ||
body: | ||
fields: [ "*" ] | ||
|
||
- match: { hits.hits.0.fields: { my.nested.keyword.field: [ abc ] } } | ||
- match: { hits.hits.1.fields: null } | ||
|
||
- do: | ||
search: | ||
index: test | ||
body: | ||
query: | ||
match: | ||
my.nested.keyword.field: abc | ||
|
||
- match: { hits.total.value: 1 } |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -2053,6 +2053,38 @@ public void testSubobjectsFalseWithInnerDottedObject() throws Exception { | |||||
assertNotNull(doc.rootDoc().getField("metrics.service.test.with.dots.max")); | ||||||
} | ||||||
|
||||||
public void testSubobjectsFalseWithInnerDottedObjectDynamicFalse() throws Exception { | ||||||
DocumentMapper mapper = createDocumentMapper(mapping(b -> { | ||||||
b.startObject("metrics").field("type", "object").field("subobjects", false).field("dynamic", randomFrom("false", "runtime")); | ||||||
b.startObject("properties").startObject("service.test.with.dots").field("type", "keyword").endObject().endObject(); | ||||||
b.endObject(); | ||||||
})); | ||||||
|
||||||
ParsedDocument doc = mapper.parse(source(""" | ||||||
{ "metrics": { "service": { "test.with.dots": "foo" } } }""")); | ||||||
assertNotNull(doc.rootDoc().getField("metrics.service.test.with.dots")); | ||||||
|
||||||
doc = mapper.parse(source(""" | ||||||
{ "metrics": { "service.test": { "with.dots": "foo" } } }""")); | ||||||
assertNotNull(doc.rootDoc().getField("metrics.service.test.with.dots")); | ||||||
|
||||||
doc = mapper.parse(source(""" | ||||||
{ "metrics": { "service": { "test": { "with.dots": "foo" } } } }""")); | ||||||
assertNotNull(doc.rootDoc().getField("metrics.service.test.with.dots")); | ||||||
|
||||||
doc = mapper.parse(source(""" | ||||||
{ "metrics": { "service": { "test.other.dots": "foo" } } }""")); | ||||||
assertNull(doc.rootDoc().getField("metrics.service.test.with.dots")); | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
here and below? |
||||||
|
||||||
doc = mapper.parse(source(""" | ||||||
{ "metrics": { "service.test": { "other.dots": "foo" } } }""")); | ||||||
assertNull(doc.rootDoc().getField("metrics.service.test.with.dots")); | ||||||
|
||||||
doc = mapper.parse(source(""" | ||||||
{ "metrics": { "service": { "test": { "other.dots": "foo" } } } }""")); | ||||||
assertNull(doc.rootDoc().getField("metrics.service.test.with.dots")); | ||||||
} | ||||||
|
||||||
public void testSubobjectsFalseRoot() throws Exception { | ||||||
DocumentMapper mapper = createDocumentMapper(mappingNoSubobjects(xContentBuilder -> {})); | ||||||
ParsedDocument doc = mapper.parse(source(""" | ||||||
|
@@ -2074,6 +2106,37 @@ public void testSubobjectsFalseRoot() throws Exception { | |||||
assertNotNull(doc.rootDoc().getField("metrics.service.test.with.dots")); | ||||||
} | ||||||
|
||||||
public void testSubobjectsFalseRootWithInnerDottedObjectDynamicFalse() throws Exception { | ||||||
DocumentMapper mapper = createDocumentMapper(topMapping(b -> { | ||||||
b.field("subobjects", false).field("dynamic", randomFrom("false", "runtime")); | ||||||
b.startObject("properties").startObject("service.test.with.dots").field("type", "keyword").endObject().endObject(); | ||||||
})); | ||||||
|
||||||
ParsedDocument doc = mapper.parse(source(""" | ||||||
{ "service": { "test.with.dots": "foo" } }""")); | ||||||
assertNotNull(doc.rootDoc().getField("service.test.with.dots")); | ||||||
|
||||||
doc = mapper.parse(source(""" | ||||||
{ "service.test": { "with.dots": "foo" } }""")); | ||||||
assertNotNull(doc.rootDoc().getField("service.test.with.dots")); | ||||||
|
||||||
doc = mapper.parse(source(""" | ||||||
{ "service": { "test": { "with.dots": "foo" } } }""")); | ||||||
assertNotNull(doc.rootDoc().getField("service.test.with.dots")); | ||||||
|
||||||
doc = mapper.parse(source(""" | ||||||
{ "service": { "test.other.dots": "foo" } }""")); | ||||||
assertNull(doc.rootDoc().getField("service.test.with.dots")); | ||||||
|
||||||
doc = mapper.parse(source(""" | ||||||
{ "service.test": { "other.dots": "foo" } }""")); | ||||||
assertNull(doc.rootDoc().getField("service.test.with.dots")); | ||||||
|
||||||
doc = mapper.parse(source(""" | ||||||
{ "service": { "test": { "other.dots": "foo" } } }""")); | ||||||
assertNull(doc.rootDoc().getField("service.test.with.dots")); | ||||||
} | ||||||
|
||||||
public void testSubobjectsFalseStructuredPath() throws Exception { | ||||||
DocumentMapper mapper = createDocumentMapper( | ||||||
mapping(b -> b.startObject("metrics.service").field("type", "object").field("subobjects", false).endObject()) | ||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we have a test that introducing a dynamic field throws in this case?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.