Reputation: 7405
Most of our data is stored in simple key/value across our platforms.
We're trying to map dynamic keys (they have a limited size).
I searched the other questions but none of the answers actually answer this simple question.
Something simple like this should work
answers: {
properties: {
fillInText: {
enabled: false,
},
comment: {
enabled: false,
},
question: {
enabled: false,
}
}
}
But it is indexing the childrens values :-/ (you can see comment here twice, potential index crash)
"answers": {
"properties": {
"comment": {
"enabled": false,
"type": "object"
},
"fillInText": {
"enabled": false,
"type": "object"
},
"do_you_like_cars": {
"properties": {
"comment": {
"fields": {
"keyword": {
"ignore_above": 256,
"type": "keyword"
}
},
"type": "text"
},
Really what we need is something simple like this, but I can't find any docs on it.
answers: {
properties: {
"*": {
properties: {
fillInText: {
enabled: false,
},
comment: {
enabled: false,
},
question: {
enabled: false,
}
}
}
}
}
Upvotes: 1
Views: 1586
Reputation: 217274
Dynamic templates with path_match
should help here. You can define your mapping like this:
PUT test
{
"mappings": {
"dynamic_templates": [
{
"fillInText": {
"path_match": "answers.*.*",
"mapping": {
"type": "object",
"enabled": false
}
}
}
]
}
}
You should, however, pay attention to the fact that this might cause mapping explosion because you could potentially create an unbounded number of fields inside answers
.
Upvotes: 3