I have a dynamic template in which I use the special value {dynamic_type}
, as I need it to work on every type that doesn't match any of my other templates. (https://www.elastic.co/guide/en/elasticsearch/reference/current/dynamic-templates.html#template-variables)
My template is something along these lines (simplified from the real deal):
{
"default-mapping": {
"match_mapping_type":"*",
"mapping": {
"type": "{dynamic_type}",
"copy_to": "__general_search"
}
}
}
ElasticSearch has moved to a new Java API Client and I want to migrate my code. (https://www.elastic.co/guide/en/elasticsearch/client/java-api-client/current/introduction.html)
The old Java API was very weakly typed and you could specify basically anything you wanted, but in the new api you have to use specific builders/methods, which are different for each type. So for a text field you'd do something like new Property.Builder().text(t -> t.copyTo("xyz"))
, for a boolean new Property.Builder().boolean_(b -> b.copyTo("xyz"))
, etc.
My question is, how do I now specify the dynamic type ({dynamic_type}
)? I can find no corresponding method/builder.
Update: I'm fairly certain this is bug/missing feature and have raised an issue for it at https://github.com/elastic/elasticsearch-java/issues/142