Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion modules/ingest-common/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ dependencies {

restResources {
restApi {
include '_common', 'ingest', 'cluster', 'indices', 'index', 'bulk', 'nodes', 'get', 'update', 'cat', 'mget', 'search', 'simulate'
include '_common', 'ingest', 'cluster', 'indices', 'index', 'bulk', 'nodes', 'get', 'update', 'cat', 'mget', 'search', 'simulate', 'capabilities'
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,381 @@
---
setup:
- requires:
reason: "Flexible access pattern was added in 9.2+"
test_runner_features: [ capabilities ]
capabilities:
- method: PUT
path: /_ingest/pipeline/{id}
capabilities: [ 'field_access_pattern.flexible' ]

---
teardown:
- do:
ingest.delete_pipeline:
id: "1"
ignore: 404

---
"Test dotted field name writes":
- do:
ingest.put_pipeline:
id: "1"
body: >
{
"field_access_pattern": "flexible",
"processors": [
{
"set": {
"field": "a.b.c.d",
"value": "1"
}
}
]
}
- match: { acknowledged: true }

- do:
index:
index: test
id: "no_field"
pipeline: "1"
body: {
foo: bar
}

- do:
index:
index: test
id: "normalized"
pipeline: "1"
body: {
a: {
b: {
c: {
d: 0
}
}
}
}

- do:
index:
index: test
id: "dotted_only"
pipeline: "1"
body: {
a.b.c.d: 0
}

- do:
index:
index: test
id: "split_dots"
pipeline: "1"
body: {
a.b: {
c.d: 0
}
}

- do:
index:
index: test
id: "middle_dot"
pipeline: "1"
body: {
a: {
b.c: {
d: 0
}
}
}

- do:
get:
index: test
id: "no_field"
- match: { _source.a\.b\.c\.d: "1" }
- do:
get:
index: test
id: "normalized"
- match: { _source.a.b.c.d: "1" }
- do:
get:
index: test
id: "dotted_only"
- match: { _source.a\.b\.c\.d: "1" }
- do:
get:
index: test
id: "split_dots"
- match: { _source.a\.b.c\.d: "1" }
- do:
get:
index: test
id: "middle_dot"
- match: { _source.a.b\.c.d: "1" }

---
"Test dotted field name retrieval":
- do:
ingest.put_pipeline:
id: "1"
body: >
{
"field_access_pattern": "flexible",
"processors": [
{
"set": {
"field": "result",
"copy_from": "a.b.c.d"
}
}
]
}
- match: { acknowledged: true }

- do:
index:
index: test
id: "normalized"
pipeline: "1"
body: {
a: {
b: {
c: {
d: 0
}
}
}
}

- do:
index:
index: test
id: "dotted_only"
pipeline: "1"
body: {
a.b.c.d: 0
}

- do:
index:
index: test
id: "split_dots"
pipeline: "1"
body: {
a.b: {
c.d: 0
}
}

- do:
index:
index: test
id: "middle_dot"
pipeline: "1"
body: {
a: {
b.c: {
d: 0
}
}
}

- do:
get:
index: test
id: "normalized"
- match: { _source.result: 0 }
- do:
get:
index: test
id: "dotted_only"
- match: { _source.result: 0 }
- do:
get:
index: test
id: "split_dots"
- match: { _source.result: 0 }
- do:
get:
index: test
id: "middle_dot"
- match: { _source.result: 0 }

---
"Test dotted field name exists":
- do:
ingest.put_pipeline:
id: "1"
body: >
{
"field_access_pattern": "flexible",
"processors": [
{
"rename": {
"field": "foo",
"target_field": "a.b.c.d",
"override": false
}
}
]
}
- match: { acknowledged: true }

- do:
catch: bad_request
index:
index: test
id: "normalized"
pipeline: "1"
body: {
foo: "bar",
a: {
b: {
c: {
d: 0
}
}
}
}
- match: { error.root_cause.0.reason: "field [a.b.c.d] already exists" }

- do:
catch: bad_request
index:
index: test
id: "dotted_only"
pipeline: "1"
body: {
foo: "bar",
a.b.c.d: 0
}
- match: { error.root_cause.0.reason: "field [a.b.c.d] already exists" }

- do:
catch: bad_request
index:
index: test
id: "split_dots"
pipeline: "1"
body: {
foo: "bar",
a.b: {
c.d: 0
}
}
- match: { error.root_cause.0.reason: "field [a.b.c.d] already exists" }

- do:
catch: bad_request
index:
index: test
id: "middle_dot"
pipeline: "1"
body: {
foo: "bar",
a: {
b.c: {
d: 0
}
}
}
- match: { error.root_cause.0.reason: "field [a.b.c.d] already exists" }

---
"Test dotted field removal":
- do:
ingest.put_pipeline:
id: "1"
body: >
{
"field_access_pattern": "flexible",
"processors": [
{
"remove": {
"field": "a.b.c.d"
}
}
]
}
- match: { acknowledged: true }

- do:
index:
index: test
id: "normalized"
pipeline: "1"
body: {
foo: "bar",
a: {
b: {
c: {
d: 0
}
}
}
}

- do:
index:
index: test
id: "dotted_only"
pipeline: "1"
body: {
foo: "bar",
a.b.c.d: 0
}

- do:
index:
index: test
id: "split_dots"
pipeline: "1"
body: {
foo: "bar",
a.b: {
c.d: 0
}
}

- do:
index:
index: test
id: "middle_dot"
pipeline: "1"
body: {
foo: "bar",
a: {
b.c: {
d: 0
}
}
}

- do:
get:
index: test
id: "normalized"
- match: { _source.foo: "bar" }
- is_false: _source.a.b.c.d
- do:
get:
index: test
id: "dotted_only"
- match: { _source.foo: "bar" }
- is_false: _source.a\.b\.c\.d
- do:
get:
index: test
id: "split_dots"
- match: { _source.foo: "bar" }
- is_false: _source.a\.b.c\.d
- do:
get:
index: test
id: "middle_dot"
- match: { _source.foo: "bar" }
- is_false: _source.a.b\.c.d
Loading