Spring-data-elasticsearch @CompletionField不会创建类型"完成"

时间:2018-02-27 12:46:37

标签: java spring-boot elasticsearch spring-data-elasticsearch

我正在使用Spring-data-elasticsearchElasticsearchTemplate个函数。

我尝试使用名为@CompletionField的{​​{1}}字段上的Completion注释创建索引。

suggest

@Document(indexName = "city", type = "city") public class City { @Id private String id; @Field private String name; @CompletionField private Completion suggest; } 注释应该用于弹性搜索的建议完成功能。就像在java-doc中描述的那样:

@CompletionField

在他们所说的elasticsearch docs中,该字段应使用类型/** * Based on the reference doc - http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-suggesters-completion.html * * @author Mewes Kochheim */ @Retention(RetentionPolicy.RUNTIME) @Target(ElementType.FIELD) @Documented @Inherited public @interface CompletionField { 来使用建议完成函数。

但是,如果我创建了我的索引,遗憾的是,complete字段的类型不是suggest,而是类型complete。当我尝试查询建议查询时,这会给我一个错误。

keyword

例外:

CompletionSuggestionBuilder s = SuggestBuilders.completionSuggestion("suggest").prefix(text, Fuzziness.ONE);
SuggestBuilder b = new SuggestBuilder().addSuggestion("test-suggest", s);
SearchResponse response = elasticsearchTemplate.suggest(b, "city");

我的所有代码都基于spring-data-elasticsearch git存储库。

ElasticsearchTemplateCompletionTests.java

CompletionAnnotatedEntity.java

我是否遗漏了java.lang.IllegalArgumentException: no mapping found for field [suggest] 文档或任何其他注释中的任何配置?

0 个答案:

没有答案