-
Notifications
You must be signed in to change notification settings - Fork 25.2k
Allow specify dynamic templates in bulk request #69948
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
Changes from 1 commit
40e6a57
eed16ef
27a538b
6ee5210
69a3849
02b2e89
96795af
8f2c6c4
3c43e98
de97281
635c395
12a87ed
f99abcd
d126606
f2e6c0f
00c6454
5679e5e
7922692
ea394f1
d77290c
290ed5c
c6468fd
58af624
6cea974
286ce59
8c9e402
d2dfda1
d5a9231
a6f9971
9c3ecba
00b92c1
a179238
dd84c8a
315c8da
0126070
b341fcc
fd87800
aef927e
8a80841
18d7b39
dccfb8e
5a22dff
a69d244
5900952
07029f0
18bcb64
bf94a83
60d11a4
d0010bd
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,46 @@ | ||
--- | ||
"Match mapping type": | ||
- skip: | ||
version: " - 7.99.99" | ||
reason: "introduced in 8.0" | ||
|
||
- do: | ||
indices.create: | ||
index: test_index | ||
body: | ||
mappings: | ||
dynamic_templates: | ||
- locations: | ||
custom_mapping_type: location_type | ||
mapping: | ||
type: geo_point | ||
- do: | ||
bulk: | ||
refresh: true | ||
body: | ||
- index: | ||
_index: test_index | ||
_id: id_1 | ||
match_mapping_types: | ||
location: location_type | ||
- location: [ -71.34, 41.12 ] | ||
- index: | ||
_index: test_index | ||
_id: id_2 | ||
match_mapping_types: | ||
location: location_type | ||
- location: "41.12,-71.34" | ||
- do: | ||
search: | ||
index: test_index | ||
body: | ||
query: | ||
geo_bounding_box: | ||
location: | ||
top_left: | ||
lat: 42 | ||
lon: -72 | ||
bottom_right: | ||
lat: 40 | ||
lon: -74 | ||
- match: { hits.total.value: 2 } | ||
dnhatn marked this conversation as resolved.
Show resolved
Hide resolved
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -543,7 +543,8 @@ private static void parseArray(ParseContext context, ObjectMapper parentMapper, | |
// TODO: shouldn't this skip, not parse? | ||
parseNonDynamicArray(context, parentMapper, lastFieldName, arrayFieldName); | ||
} else { | ||
Mapper objectMapperFromTemplate = dynamic.getDynamicFieldsBuilder().createObjectMapperFromTemplate(context, arrayFieldName); | ||
Mapper objectMapperFromTemplate = | ||
dynamic.getDynamicFieldsBuilder().createFieldOrObjectMapperFromTemplate(context, arrayFieldName); | ||
if (objectMapperFromTemplate == null) { | ||
parseNonDynamicArray(context, parentMapper, lastFieldName, arrayFieldName); | ||
} else { | ||
|
@@ -711,7 +712,12 @@ private static Tuple<Integer, ObjectMapper> getDynamicParentMapper(ParseContext | |
return new Tuple<>(pathsAdded, parent); | ||
} else { | ||
//objects are created under properties even with dynamic: runtime, as the runtime section only holds leaf fields | ||
mapper = (ObjectMapper) dynamic.getDynamicFieldsBuilder().createDynamicObjectMapper(context, paths[i]); | ||
final Mapper fieldMapper = dynamic.getDynamicFieldsBuilder().createDynamicObjectMapper(context, paths[i]); | ||
if (fieldMapper instanceof ObjectMapper == false) { | ||
throw new MapperParsingException("Field [" + context.path().pathAsText(paths[i]) + "] must be an object; " + | ||
"but it's configured as [" + fieldMapper.typeName() + "] in dynamic templates"); | ||
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. Question: can this happen in reality? If so do we have a test for it? I am wondering if this became relevant with the previous iteration but it may no longer be the case now that hints are separate from types. Maybe we should rather have an assertion in createDynamicObjectMapper and cast there so that its return type can be the right one? This is unrelated to your PR though :) 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. I still wonder about this added conditional ;) 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. I added a test for this in a6f9971. |
||
} | ||
mapper = (ObjectMapper) fieldMapper; | ||
if (mapper.nested() != ObjectMapper.Nested.NO) { | ||
throw new MapperParsingException("It is forbidden to create dynamic nested objects ([" | ||
+ context.path().pathAsText(paths[i]) + "]) through `copy_to` or dots in field names"); | ||
|
Uh oh!
There was an error while loading. Please reload this page.