Custom mapping / dynamic_templates json_data

Hello,

I'm trying to index a document which has a property called "json_data" (type "object").
{
"json_data": {"id": 1, "level": 1, "data": {another json...}}
}

I'm trying to create a template with dynamic_templates so that every value of "json_data" on every level (id, level, data.key1, data.key2, data.key1.subkey1... etc) to be indexed as string.

The error I get is:

"status"=>400,
"error"=>{"type"=>"mapper_parsing_exception", "reason"=>"failed to parse [json_data.data]", "caused_by"=>{"type"=>"illegal_state_exception", "reason"=>"Can't get text on a START_OBJECT at 1:55"}}

How can I apply dynamic_templates/mapping for all the properties/subproperties of this object? I don't know the names of the properties in advance so I need to use dynamic_templats.

{
"template" : "logstash-",
"mappings" : {
"default" : {
"dynamic_templates" : [
{
"json_data_as_strings" : {
"path_match" : "json_data.
",
"mapping" : {
"type" : "string",
"index": "not_analyzed",
}
}
}
]
}
}
}

Thank you,

Hi,

Did you see 'path_match' ?
https://www.elastic.co/guide/en/elasticsearch/reference/5.3/dynamic-templates.html#path-match-unmatch

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