Skip to content

Commit

Permalink
Fix _bulk api dynamic_templates and explicit op_type (#92687)
Browse files Browse the repository at this point in the history
  • Loading branch information
joegallo committed Jan 5, 2023
1 parent b05770b commit 34ed7ee
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 6 deletions.
5 changes: 5 additions & 0 deletions docs/changelog/92687.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
pr: 92687
summary: 'Fix `_bulk` api `dynamic_templates` and explicit `op_type`'
area: Mapping
type: bug
issues: []
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,20 @@
bulk:
refresh: true
body:
- index:
- create:
_index: test_index
_id: id_1
dynamic_templates:
location: location
- { "location": [ -71.34, 41.12 ]}
- { "location": "41.12,-71.34"}
- index:
_index: test_index
_id: id_2
dynamic_templates:
location: location
- { "location": "41.12,-71.34"}
- { "location": [ -71.34, 41.12 ]}
- match: { errors: false }
- match: { items.0.index.result: created }
- match: { items.0.create.result: created }
- match: { items.1.index.result: created }

- do:
Expand Down Expand Up @@ -65,7 +65,7 @@
_index: test_index
_id: id_3
- { "my_location": "41.12,-71.34" } # matches the field name defined in the `my_location` template
- index:
- create:
_index: test_index
_id: id_4
dynamic_templates:
Expand Down Expand Up @@ -169,3 +169,64 @@
- match: { items.0.index.error.reason: "failed to parse field [foo] of type [keyword] in document with id 'id_11'. Preview of field's value: '{bar=hello world}'"}
- match: { items.1.index.status: 201 }
- match: { items.1.index.result: created }

---
"Dynamic templates with op_type":
- skip:
version: " - 8.6.0"
reason: "bug fixed in 8.6.1"

- do:
indices.create:
index: test_index
body:
mappings:
dynamic_templates:
- location:
mapping:
type: geo_point
- my_location:
match: my*
mapping:
type: geo_point
- string:
mapping:
type: keyword
- do:
bulk:
refresh: true
body:
- index:
_index: test_index
_id: id_1
op_type: create
dynamic_templates:
location: location
- { "location": "41.12,-71.34"}
- index:
_index: test_index
_id: id_2
op_type: index
dynamic_templates:
location: location
- { "location": [ -71.34, 41.12 ]}
- match: { errors: false }
- match: { items.0.create.result: created }
- match: { items.1.index.result: created }

- 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 }
- match: { hits.hits.0._id: id_1 }
- match: { hits.hits.1._id: id_2 }
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,7 @@ public void parse(
.setIfSeqNo(ifSeqNo)
.setIfPrimaryTerm(ifPrimaryTerm)
.source(sliceTrimmingCarriageReturn(data, from, nextMarker, xContentType), xContentType)
.setDynamicTemplates(dynamicTemplates)
.setRequireAlias(requireAlias),
type
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
* _index, _id and _routing must be a String or null
* _version_type must be a lower case VersionType or null
* _version must be representable as a long without loss of precision or null
* _dyanmic_templates must be a map
* _dynamic_templates must be a map
* _if_seq_no must be a long or null
* _if_primary_term must be a long or null
*
Expand Down

0 comments on commit 34ed7ee

Please sign in to comment.