Skip to content

[Ingest] Add support for array/list access in path  #14324

@talevy

Description

@talevy

The ingest plugin's Data class currently supports retrieval of a value using a path to a field specified in dot-notation (e.g. foo.bar). For more complex insertions, updates, and retrievals of nested fields within the document, it would be useful to be able to access fields through array/list typed fields.

The notation proposed here is to introduce a path element in the specified path that is an integer and is to be evaluated as an index into the parent array/list object.

# example paths
foo.bar.1.first
foo.4
foo.4.3.6.last

Here is an example:

data = new Data("index", "type", "id",
                new HashMap<String, Object>() {{
                    put("foo", Arrays.asList("a", "b", "c");
                    put("fizz", new HashMap<String, Object>() {{
                        put("buzz", "hello world");
                    }});
                }});
assertThat(data.getProperty("foo.1"), equalTo("b"))

addField is also meant to support this behavior. more functions will have to be introduced to distinguish between an append to an array, and a full replace.

Metadata

Metadata

Assignees

Labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions