你的浏览器禁用了JavaScript, 请开启后刷新浏览器获得更好的体验!
输入关键字进行搜索
搜索:
没有找到相关结果
kennywu76 - Wood
赞同来自: medcl 、liujia
mn_1127 - 80后it男
赞同来自:
/** * 自动补全查询功能 * 注意字段book_suggest必须是completion类型的 */ @test public void testCompletionSuggest() { CompletionSuggestionBuilder suggestionBuilder = new CompletionSuggestionBuilder("book_suggest"); suggestionBuilder.analyzer("ik_smart"); suggestionBuilder.text("特工"); suggestionBuilder.size(200); SuggestBuilder sb = new SuggestBuilder(); sb.addSuggestion("my-suggest-1", suggestionBuilder); SearchResponse resp = client.prepareSearch().setIndices("ytxt").setTypes("book_info") .setQuery(QueryBuilders.matchAllQuery()).suggest(sb).get(); Suggest sugg = resp.getSuggest(); CompletionSuggestion suggestion = sugg.getSuggestion("my-suggest-1"); List<CompletionSuggestion.Entry> list = suggestion.getEntries(); for (int i = 0; i < list.size(); i++) { List<?> options = list.get(i).getOptions(); for (int j = 0; j < options.size(); j++) { if (options.get(j) instanceof Option) { Option op = (Option) options.get(j); System.out.println(op.getScore()+"--"+op.getText()); } } } }
要回复问题请先登录或注册
80后it男
3 个回复
kennywu76 - Wood
赞同来自: medcl 、liujia
mn_1127 - 80后it男
赞同来自:
mn_1127 - 80后it男
赞同来自: