Mapping all nested fields

Hello, everyone.

I'm trying to index an object like this (shown partially):

...
"stats": {
    "stats_0": "0",
    "stats_0": "0",
    ...
    "stats_99": "99"
}
...

But I'm not being successful: It's indexed as string and I need it to be of numeric type. I think there's two approaches to this problem: 1) provide mappings to those fields or 2) convert those nested fields into long in the pipeline. The problem is I don't know how to do this in a compact way. I don't want to write

...
"stats": {
    "properties": {
        "stats0": {
            "type": "long"
        }
       "stats1": {
            "type": "long"
        }
        ...
       "stats99": {
            "type": "long"
        }
    }
}
...

There must be a way to do this for all nested fields at once.

Sorry if it was unclear.

Thank you.

This is more of an Elasticsearch question so you'll probably have more luck moving your post to that category.

Moved. Thanks.

You have some options.

  1. Use Numeric detection
    you can control which level is enabled/disabled.
  2. Use dynamic templates
    If there are some rules for field name, e.x. stats_*, you can define custom mappings by dynamic templates

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.