I looked through the previous problem records, and my question should be: does the latest javaapi support custom tokenizer
Excuse me, I have some questions about the Java client. I need to register setting in elastic that supports the "pinyin" plug-in. When I write this, I find that the plug-in cannot be configured. What should I do?
Reader pinyinJson = new StringReader(
"{\n" +
" \"type\": \"pinyin\",\n" +
" \"keep_separate_first_letter\": false,\n" +
" \"keep_full_pinyin\": true,\n" +
" \"keep_original\": true,\n" +
" \"limit_first_letter_length\": 16,\n" +
" \"lowercase\": true,\n" +
" \"remove_duplicated_term\": true\n" +
"}"
);
tokenizerMap.put("pinyin_tokenizer", new Tokenizer.Builder() //<---this
.definition(new TokenizerDefinition.Builder()
.withJson(pinyinJson).build()).build());
CreateIndexResponse createIndexResponse = elasticClient.indices().create(c -> c
.index(index)
.aliases(aliases, a -> a
.isWriteIndex(true))
.settings(s -> s
.analysis(a -> a
.filter(filterMap)
.normalizer(normalizerMap)
.analyzer(analyzerMap)
.tokenizer(tokenizerMap))
.numberOfShards("1")
.numberOfReplicas("1"))
.mappings(typeMapping));
The error message is
Caused by: jakarta.json.stream.JsonParsingException: Unknown field 'pinyin' for type 'co.elastic.clients.elasticsearch._types.analysis.TokenizerDefinition$Builder'
at co.elastic.clients.json.ObjectDeserializer.parseUnknownField(ObjectDeserializer.java:213)
at co.elastic.clients.json.ObjectDeserializer.deserialize(ObjectDeserializer.java:190)
at co.elastic.clients.util.WithJsonObjectBuilderBase.withJson(WithJsonObjectBuilderBase.java:66)
at co.elastic.clients.json.WithJson.withJson(WithJson.java:57)
at com.inventec.itc.service.elastic.ElasticIndexBuilder.lambda$createIndex$0(ElasticIndexBuilder.java:238)
at co.elastic.clients.elasticsearch._types.analysis.Tokenizer$Builder.definition(Tokenizer.java:149)
at com.inventec.itc.service.elastic.ElasticIndexBuilder.createIndex(ElasticIndexBuilder.java:237)
at com.inventec.itc.service.elastic.ElasticIndexBuilder.indexBuilder(ElasticIndexBuilder.java:42)
at com.inventec.itc.factory.ElasticInitFactory.afterPropertiesSet(ElasticInitFactory.java:25)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1863)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1800)
... 86 more