本文整理汇总了Java中org.elasticsearch.search.suggest.completion.CompletionSuggestionFuzzyBuilder类的典型用法代码示例。如果您正苦于以下问题:Java CompletionSuggestionFuzzyBuilder类的具体用法?Java CompletionSuggestionFuzzyBuilder怎么用?Java CompletionSuggestionFuzzyBuilder使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
CompletionSuggestionFuzzyBuilder类属于org.elasticsearch.search.suggest.completion包,在下文中一共展示了CompletionSuggestionFuzzyBuilder类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getCompletionSuggest
import org.elasticsearch.search.suggest.completion.CompletionSuggestionFuzzyBuilder; //导入依赖的package包/类
/**
* 无奈es的版本太低了,无法在建议器中做过滤操作(笔者es版本1.1),在更高版本的es中可以通过Context Suggester做过滤
*
* @param indices
* @param suggestQuery
* @return
*/
@SuppressWarnings({ "unchecked" })
private static List<Map<String, Object>> getCompletionSuggest(String indices,
SuggestQuery suggestQuery) {
// 查询体
CompletionSuggestionFuzzyBuilder suggestionsBuilder = new CompletionSuggestionFuzzyBuilder(
suggestQuery.suggestName);
suggestionsBuilder.setFuzziness(Fuzziness.build(suggestQuery.getFuzziness()));
suggestionsBuilder.text(suggestQuery.getText());
suggestionsBuilder.field(suggestQuery.getField());
suggestionsBuilder.size(suggestQuery.getSize());
SuggestRequestBuilder suggestRequestBuilder = ESClient.getClient()
.prepareSuggest(indices.split(",")).addSuggestion(suggestionsBuilder);
SuggestResponse resp = suggestRequestBuilder.execute().actionGet();
// 查询结果
List<? extends Entry<? extends Option>> entries = (List<? extends Entry<? extends Option>>) resp
.getSuggest().getSuggestion(suggestQuery.suggestName).getEntries();
if (entries == null) {
return Lists.newArrayList();
}
List<Map<String, Object>> result = new ArrayList<Map<String, Object>>();
for (Entry<? extends Option> e : entries) {
for (Option option : e) {
Map<String, Object> map_payload = option.getPayloadAsMap();
map_payload.put("NAME", option.getText().toString());
result.add(map_payload);
}
}
// 调试模式
if (Constants.isDebug) {
logger.info(suggestRequestBuilder.toString());
logger.info(suggestionsBuilder.toString());
logger.info(JsonUtil.toJson(result));
}
return result;
}
示例2: completionFuzzy
import org.elasticsearch.search.suggest.completion.CompletionSuggestionFuzzyBuilder; //导入依赖的package包/类
public SimpleSuggestionBuilder completionFuzzy(Consumer<CompletionSuggestionFuzzyBuilder> consumer){
CompletionSuggestionFuzzyBuilder completion = new CompletionSuggestionFuzzyBuilder(name).field(field).text(text);
build(completion, consumer);
return this;
}
示例3: fuzzyCompletionSuggestion
import org.elasticsearch.search.suggest.completion.CompletionSuggestionFuzzyBuilder; //导入依赖的package包/类
/**
* Creates a fuzzy completion suggestion lookup query with the provided <code>name</code>
*
* @param name The suggestion name
* @return a {@link org.elasticsearch.search.suggest.completion.CompletionSuggestionFuzzyBuilder}
* instance
*/
public static CompletionSuggestionFuzzyBuilder fuzzyCompletionSuggestion(String name) {
return new CompletionSuggestionFuzzyBuilder(name);
}