我发现了问题。似乎钥匙不应该包括
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);
}