当前位置: 首页>>代码示例>>Java>>正文


Java SuggestionSearchContext类代码示例

本文整理汇总了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;
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:19,代码来源:TermSuggestParser.java

示例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);
    }
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:31,代码来源:TransportSuggestAction.java

示例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;
}
 
开发者ID:meltwater,项目名称:es-prefix-suggester,代码行数:12,代码来源:PrefixSuggester.java

示例4: suggest

import org.elasticsearch.search.suggest.SuggestionSearchContext; //导入依赖的package包/类
@Override
public SuggestionSearchContext suggest() {
    return null;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:5,代码来源:TestSearchContext.java

示例5: suggest

import org.elasticsearch.search.suggest.SuggestionSearchContext; //导入依赖的package包/类
@Override
public SuggestionSearchContext suggest() {
    return in.suggest();
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:5,代码来源:FilteredSearchContext.java

示例6: suggest

import org.elasticsearch.search.suggest.SuggestionSearchContext; //导入依赖的package包/类
@Override
public SuggestionSearchContext suggest() {
    return suggest;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:5,代码来源:DefaultSearchContext.java

示例7: suggest

import org.elasticsearch.search.suggest.SuggestionSearchContext; //导入依赖的package包/类
@Override
public SuggestionSearchContext suggest() {
    throw new UnsupportedOperationException();
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:5,代码来源:PercolateContext.java

示例8: suggest

import org.elasticsearch.search.suggest.SuggestionSearchContext; //导入依赖的package包/类
public abstract SuggestionSearchContext suggest(); 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:2,代码来源:SearchContext.java


注:本文中的org.elasticsearch.search.suggest.SuggestionSearchContext类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。