Maybe I'm missing something simple, but still could not figure out the following thing:
As of ES 6.x the _all
field is deprecated, and instead it's suggested to use the copy_to
instruction (https://www.elastic.co/guide/en/elasticsearch/reference/current/copy-to.html).
However, I got an impression that you need to explicitly specify the fields which you want to copy to the custom _all
field. But if I use dynamic mappings, I don't know the fields in advance, and therefore cannot use copy_to
?
Any way I can tell ES to copy all encountered fields to the custom _all
field so that I can search across all fields?
Thanks in advance!
You could use Dynamic Templates. Basically create an index, add the custom catch_all
field and then specify that particular property for all the fields that are strings. (Haven't done this before, but I believe this is the only way now. Since the field catch_all
will be already present when you put the dynamic template, it will not match the catch_all
- meaning that the catch_all
will not copy to itself, but check it out yourself to make sure).
PUT my_index
{
"mappings": {
"_doc": {
"dynamic_templates": [
{
"strings": {
"match_mapping_type": "string",
"mapping": {
"type": "text",
"copy_to": "catch_all"
}
}
}
]
}
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With