Reputation: 5229
I'm using Elasticsearch alias fields to rename some fields in my mapping without needing to reindex everything. Works great. Now I want to rename some multi fields as well, like this:
"message":{
"type":"text",
"fields":{
"raw":{
"type":"keyword"
}
}
}
That's an analyzed field named message
and a keyword version named message.raw
. I can make an alias for message
like this:
"title":{
"type":"alias",
"path":"message"
}
But I cannot seem to figure out how to alias the message.raw
field. I tried different things.
Suspected that this would work out of the box by just using title.raw and hoping that Elasticsearch would convert it to message.raw. Didn't work.
Specified raw
as a field in title
:
"title":{
"type":"alias",
"path":"message",
"fields":{
"raw":{
"type":"alias",
"path":"message.raw"
}
}
}
This generates the following error when updating the mapping: Mapping definition for [title] has unsupported parameters: [fields : {raw={type=alias, path=message.raw}}]
title.raw
as a new field:"title":{
"type":"alias",
"path":"message"
},
"title.raw":{
"type":"alias",
"path":"message.raw"
}
This results in an error: Cannot merge a field alias mapping [title] with a mapping that is not for a field alias.
Is this supported somehow?
Upvotes: 0
Views: 1887
Reputation: 217254
Referencing multi-fields from an alias isn't supported. From the documentation:
aliases cannot be used as the target of copy_to or in multi-fields
.
You can create an alias for your multi-field without the dot. What you need to do is simply to name the title.raw
field differently, e.g. title_raw
:
"title":{
"type":"alias",
"path":"message"
},
"title_raw":{ <--- change the name here
"type":"alias",
"path":"message.raw"
}
Then you can query message.raw
the same way as title_raw
.
Upvotes: 1