gpt4 book ai didi

java - ElasticSearch 高级 API 使用自定义设置创建索引返回错误

转载 作者:行者123 更新时间:2023-12-02 10:21:13 34 4
gpt4 key购买 nike

我正在尝试使用自定义设置创建广告索引,如所述 here 。我正在使用 ElasticSearch 6.3

这是我的代码:

public CreateIndexResponse createIndex(@NotNull String indexName) throws IOException {
CreateIndexRequest request = new CreateIndexRequest();
request.index(indexName);
Settings.Builder settingsBuilder =
Settings.builder()
.put("settings.analysis.filter.autocomplete_filter.type", "edge_ngram")
.put("settings.analysis.filter.autocomplete_filter.min_gram", "1")
.put("settings.analysis.filter.autocomplete_filter.max_gram", "10")
.put("settings.analysis.analyzer.autocomplete.type", "custom")
.put("settings.analysis.analyzer.autocomplete.tokenizer", "standard")
.putList("settings.analysis.analyzer.autocomplete.filter", "lowercase", "autocomplete_filter");
request.settings(settingsBuilder);
return elasticSearchClient.indices().create(request, RequestOptions.DEFAULT);
}

但我有这个异常(exception):

ElasticsearchStatusException[Elasticsearch exception [type=illegal_argument_exception, reason=unknown setting [index.settings.analysis.analyzer.autocomplete.filter] please check that any required plugins are installed, or check the breaking changes documentation for removed settings]]

我正在使用 AWS ElasticSearch 实例。我更喜欢使用构建器而不是纯 JSON 来创建我的设置请求。我做错了什么吗?

最佳答案

我发现了问题。看来按键不能包含 settings 前缀。

工作代码是这样的:

public CreateIndexResponse createIndex(@NotNull String indexName) throws IOException {
CreateIndexRequest request = new CreateIndexRequest();
request.index(indexName);
Settings.Builder settingsBuilder =
Settings.builder()
.put("analysis.filter.autocomplete_filter.type", "edge_ngram")
.put("analysis.filter.autocomplete_filter.min_gram", "1")
.put("analysis.filter.autocomplete_filter.max_gram", "10")
.put("analysis.analyzer.autocomplete.type", "custom")
.put("analysis.analyzer.autocomplete.tokenizer", "standard")
.putList("analysis.analyzer.autocomplete.filter", "lowercase", "autocomplete_filter");
request.settings(settingsBuilder);
return elasticSearchClient.indices().create(request, RequestOptions.DEFAULT);
}

关于java - ElasticSearch 高级 API 使用自定义设置创建索引返回错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54330661/

34 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com