本文整理汇总了Java中org.elasticsearch.search.suggest.SuggestionSearchContext类的典型用法代码示例。如果您正苦于以下问题:Java SuggestionSearchContext类的具体用法?Java SuggestionSearchContext怎么用?Java SuggestionSearchContext使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
SuggestionSearchContext类属于org.elasticsearch.search.suggest包,在下文中一共展示了SuggestionSearchContext类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: parse
import org.elasticsearch.search.suggest.SuggestionSearchContext; //导入依赖的package包/类
@Override
public SuggestionSearchContext.SuggestionContext parse(XContentParser parser, MapperService mapperService,
IndexQueryParserService queryParserService, HasContextAndHeaders headersContext) throws IOException {
XContentParser.Token token;
String fieldName = null;
TermSuggestionContext suggestion = new TermSuggestionContext(suggester);
DirectSpellcheckerSettings settings = suggestion.getDirectSpellCheckerSettings();
while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) {
if (token == XContentParser.Token.FIELD_NAME) {
fieldName = parser.currentName();
} else if (token.isValue()) {
parseTokenValue(parser, mapperService, fieldName, suggestion, settings, queryParserService.parseFieldMatcher());
} else {
throw new IllegalArgumentException("suggester[term] doesn't support field [" + fieldName + "]");
}
}
return suggestion;
}
示例2: shardOperation
import org.elasticsearch.search.suggest.SuggestionSearchContext; //导入依赖的package包/类
@Override
protected ShardSuggestResponse shardOperation(ShardSuggestRequest request) {
IndexService indexService = indicesService.indexServiceSafe(request.shardId().getIndex());
IndexShard indexShard = indexService.shardSafe(request.shardId().id());
ShardSuggestMetric suggestMetric = indexShard.getSuggestMetric();
suggestMetric.preSuggest();
long startTime = System.nanoTime();
XContentParser parser = null;
try (Engine.Searcher searcher = indexShard.acquireSearcher("suggest")) {
BytesReference suggest = request.suggest();
if (suggest != null && suggest.length() > 0) {
parser = XContentFactory.xContent(suggest).createParser(suggest);
if (parser.nextToken() != XContentParser.Token.START_OBJECT) {
throw new IllegalArgumentException("suggest content missing");
}
final SuggestionSearchContext context = suggestPhase.parseElement().parseInternal(parser, indexService.mapperService(),
indexService.queryParserService(), request.shardId().getIndex(), request.shardId().id(), request);
final Suggest result = suggestPhase.execute(context, searcher.searcher());
return new ShardSuggestResponse(request.shardId(), result);
}
return new ShardSuggestResponse(request.shardId(), new Suggest());
} catch (Throwable ex) {
throw new ElasticsearchException("failed to execute suggest", ex);
} finally {
if (parser != null) {
parser.close();
}
suggestMetric.postSuggest(System.nanoTime() - startTime);
}
}
示例3: queryTerms
import org.elasticsearch.search.suggest.SuggestionSearchContext; //导入依赖的package包/类
private List<Term> queryTerms(SuggestionSearchContext.SuggestionContext suggestion, CharsRefBuilder spare) throws IOException {
final String field = suggestion.getField();
final List<Term> ret = new ArrayList<Term>();
SuggestUtils.analyze(suggestion.getAnalyzer(), suggestion.getText(), field, new SuggestUtils.TokenConsumer() {
@Override
public void nextToken() {
ret.add(new Term(field, BytesRef.deepCopyOf(fillBytesRef(new BytesRefBuilder()))));
}
}, spare);
return ret;
}
示例4: suggest
import org.elasticsearch.search.suggest.SuggestionSearchContext; //导入依赖的package包/类
@Override
public SuggestionSearchContext suggest() {
return null;
}
示例5: suggest
import org.elasticsearch.search.suggest.SuggestionSearchContext; //导入依赖的package包/类
@Override
public SuggestionSearchContext suggest() {
return in.suggest();
}
示例6: suggest
import org.elasticsearch.search.suggest.SuggestionSearchContext; //导入依赖的package包/类
@Override
public SuggestionSearchContext suggest() {
return suggest;
}
示例7: suggest
import org.elasticsearch.search.suggest.SuggestionSearchContext; //导入依赖的package包/类
@Override
public SuggestionSearchContext suggest() {
throw new UnsupportedOperationException();
}
示例8: suggest
import org.elasticsearch.search.suggest.SuggestionSearchContext; //导入依赖的package包/类
public abstract SuggestionSearchContext suggest();