Error deserializing co.elastic.clients.elasticsearch._types.analysis.Analyzer: Property 'type' not found
Java API client version
8.4.0
Java version
JDK-17
Elasticsearch Version
7.17.2
Problem description
Trying to read settings for an index, throwing Error deserializing co.elastic.clients.elasticsearch._types.analysis.Analyzer: Property 'type' not found Exception
var indexSetting = new GetIndicesSettingsRequest.Builder().index("index_1000").build();
try {
var settings = elasticSearchClientConfig.getElasticsearchIndicesClient().getSettings(indexSetting);
System.out.println(settings);
} catch(Exception e) {
e.printStackTrace();
}
Settings
{
"index_1000": {
"settings": {
"index": {
"analysis": {
"analyzer": {
"edgengram-analyzer": {
"tokenizer": "edge_ngram_tokenizer"
}
}
}
}
}
}
}
Exception trace
Error deserializing co.elastic.clients.elasticsearch._types.analysis.Analyzer: Property 'type' not found (JSON path: index_1000.settings.index.analysis.analyzer['edgengram-analyzer']) (line no=1, column no=56407, offset=-1)
@swallez Please help fixing this.
We've seen this as well in testing.
This also happens for me with library versions 7.17.6 and 8.4.1 with the Get Index API, à la
client.indices().get(builder -> builder.index("*"))
It's a show-stopper for migrating to the Java Client, away from the RestHighLevelClient!
We're hitting this too in trying to migrate
FYI I'm able to workaround this via the following (kotlin):
val unwrapped = DelegatingDeserializer.unwrap(Analyzer._DESERIALIZER) as ObjectDeserializer<*>
unwrapped.setTypeProperty("type", "custom")
EDIT: simpler
FYI I'm able to workaround this via the following (kotlin):
Analyzer._DESERIALIZER .let { DelegatingDeserializer.unwrap(it) } .let { DelegatingDeserializer.unwrap(it) } .let { unwrapped -> unwrapped as ObjectDeserializer<*> unwrapped.setTypeProperty("type", "custom") }
Don't know how to port this to Java, still looking...
Work around Java version, thanks a ton @rockwotj
ObjectDeserializer unwrapped = (ObjectDeserializer) DelegatingDeserializer.unwrap(Analyzer._DESERIALIZER );
unwrapped.setTypeProperty("type", "custom");
or just add "type": "custom", to json.
even if it is default value, i really needs.
{
"index_1000": {
"settings": {
"index": {
"analysis": {
"analyzer": {
"edgengram-analyzer": {
"type": "custom",
"tokenizer": "edge_ngram_tokenizer"
}
}
}
}
}
}
}