Can the field type (e.g. "flattened") be specified at time of indexing?

I know I can specify that a specific field has the type "flattened" (Flattened field type | Elasticsearch Guide [8.0] | Elastic) by specifying that in the index _mapping but is there a way to do that when indexing?

I want the type of a to be flattened.
curl -XPUT -H 'Content-type: application/json' --data-binary '{"a":{"p1":"foo"}}' localhost:9200/test1/_doc/1

If you have created the index with that mapping before indexing, then it'll be applied.

Otherwise Elasticsearch will do a best guess at mapping (ie dynamic mappings).

1 Like

Thanks, okay. And unfortunately there's no way to make a field look "flattened" so there's no way for that type to be automatically used without an explicit mapping.

does dynamic_templates meet your needs?

Thanks, dynamic_templates would work but I'm trying to index a flattened field without updating the schema mappings.

I was trying to deploy a new version of my application which adds this field without requiring a separate, manual schema update. But I guess there's no way.

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