我在Rest High Level Client中使用弹性7。 我需要在SuggestionBuilder中添加上下文,以便在弹性中搜索
我尝试了此链接ElasticSearch 5 adding context to SuggestionBuilders中提到的解决方案。
尝试上述解决方案后,我在Eclipse中遇到以下错误:
“ CompletionSuggestionBuilder类型的方法上下文(Map
SuggestionBuilder suggestionBuilder = SuggestBuilders.completionSuggestion("suggest").prefix("test").contexts(Collections.singletonMap("cat", Collections.singletonList(CategoryQueryContext.builder().setCategory("cat0").build())));
SuggestBuilder suggestBuilder = new SuggestBuilder();
suggestBuilder.addSuggestion("test123", suggestionBuilder);
SearchRequest searchRequest = new SearchRequest("autocomplete_5cc0ca7265675c6b769d976c");
SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
searchSourceBuilder.suggest(suggestBuilder);
searchRequest.source(searchSourceBuilder);
SearchResponse searchResponse = client.search(searchRequest, RequestOptions.DEFAULT);
预期要添加到suggestationBuilder对象中的上下文