Hello,
I have some data with an object named "data". I need to perform aggregations by fields inside the "data" object, so I need the keyword type for all strings. At the same time, I need to set the ignore_malformed to true for other types.
I realized that this mapping automatically disables the keyword extra field for all strings inside "data"... ¿?
DELETE /_template/test
PUT /_template/test
{
"index_patterns": ["test"],
"mappings": {
"properties": {
"data": {
"type": "object"
}
},
"dynamic_templates": [
{
"data": {
"path_match": "data.*",
"mapping": { "ignore_malformed": true }
}
}
]
}
}
DELETE /test
PUT /test/_doc/1
{
"data.field": "hellow world"
}
GET /test/_mapping/
Output:
{
"test" : {
"mappings" : {
"dynamic_templates" : [
{
"data" : {
"path_match" : "data.*",
"mapping" : {
"ignore_malformed" : true
}
}
}
],
"properties" : {
"data" : {
"properties" : {
"field" : {
"type" : "text"
}
}
}
}
}
}
}
Just removing the dynamic mapping (for ignore_malformed), I get the expected extra keyword field:
{
"test" : {
"mappings" : {
"properties" : {
"data" : {
"properties" : {
"field" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
}
}
}
}
}
}
}
Setting an extra mapping to set strings to keyword does not work, since it looks like only the first rule that matches is applied:
DELETE /_template/test
PUT /_template/test
{
"index_patterns": ["test"],
"mappings": {
"properties": {
"data": {
"type": "object"
}
},
"dynamic_templates": [
{
"data": {
"path_match": "data.*",
"mapping": { "ignore_malformed": true }
}
},
{
"data_keyword": {
"path_match": "data.*",
"match_mapping_type": "string",
"mapping": { "type": "keyword" }
}
}
]
}
}
DELETE /test
PUT /test/_doc/1
{
"data.field": "hellow world"
}
GET /test/_mapping
Output:
{
"test" : {
"mappings" : {
"dynamic_templates" : [
{
"data" : {
"path_match" : "data.*",
"mapping" : {
"ignore_malformed" : true
}
}
},
{
"data_keyword" : {
"path_match" : "data.*",
"match_mapping_type" : "string",
"mapping" : {
"type" : "keyword"
}
}
}
],
"properties" : {
"data" : {
"properties" : {
"field" : {
"type" : "text"
}
}
}
}
}
}
}
So.. how can I get the ignore_malformed set to true and at the same time keyword type for my string fields?