Skip to content

Expand dotted fields recursively #36950

@ycombinator

Description

@ycombinator

I'm trying to index a document like this into Elasticsearch:

{
  "foo.bar": 17,
  "foo.baz": 23
}

I would like to expand the foo field into an object, so the document that gets indexed looks like this:

{
  "foo": {
    "bar": 17,
    "baz": 23
  }
}

I can use the dot_expander Ingest processor to perform the expansion by defining a pipeline like so:

{
  "pipeline": {
    "description": "Ze un-flattener!!!", 
    "processors": [
      {
        "dot_expander": {
          "field": "foo.bar"
        }
      },
      {
        "dot_expander": {
          "field": "foo.baz"
        }
      }
    ]
  }
}

However, if I were to later add another sub-field under foo in my source document, I would have to update the Ingest pipeline with another dot_expander processor to handle that sub-field as well.

It would nice if the dot_expander processor supported an option to expand a given field recursively, something like this:

{
  "dot_expander": {
    "field": "foo",
    "recursive": true
  }
}

Thanks!

Metadata

Metadata

Assignees

No one assigned

    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