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


Java SearchHit.getScore方法代码示例

本文整理汇总了Java中org.elasticsearch.search.SearchHit.getScore方法的典型用法代码示例。如果您正苦于以下问题:Java SearchHit.getScore方法的具体用法?Java SearchHit.getScore怎么用?Java SearchHit.getScore使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.elasticsearch.search.SearchHit的用法示例。


在下文中一共展示了SearchHit.getScore方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: search

import org.elasticsearch.search.SearchHit; //导入方法依赖的package包/类
@Override
public Scores search(SearchQueryHolder holder) {
    String modelName = holder.getSearchParams().getKbId().getType();
    Class<Serializable> modelClass = core.getModelClass(modelName);

    ElasticScroller scroller = new ElasticScroller(esClient, holder) {
        @Override
        protected Score build(SearchHit hit) {
            try {
                Serializable entity = mapper.readValue(hit.source(), modelClass);
                return new Score(entity, hit.getScore());
            } catch (Exception e) {
                logger.error(marker, "Fail to deserialize {}", hit.sourceAsString(), e);
            }
            return null;
        }
    };

    return scroller.getScores();
}
 
开发者ID:Lambda-3,项目名称:Stargraph,代码行数:21,代码来源:ElasticSearcher.java

示例2: fromXContent

import org.elasticsearch.search.SearchHit; //导入方法依赖的package包/类
public static Option fromXContent(XContentParser parser) {
    Map<String, Object> values = PARSER.apply(parser, null);

    Text text = new Text((String) values.get(Suggestion.Entry.Option.TEXT.getPreferredName()));
    Float score = (Float) values.get(Suggestion.Entry.Option.SCORE.getPreferredName());
    @SuppressWarnings("unchecked")
    Map<String, Set<CharSequence>> contexts = (Map<String, Set<CharSequence>>) values
            .get(CompletionSuggestion.Entry.Option.CONTEXTS.getPreferredName());
    if (contexts == null) {
        contexts = Collections.emptyMap();
    }

    SearchHit hit = null;
    // the option either prints SCORE or inlines the search hit
    if (score == null) {
        hit = SearchHit.createFromMap(values);
        score = hit.getScore();
    }
    CompletionSuggestion.Entry.Option option = new CompletionSuggestion.Entry.Option(-1, text, score, contexts);
    option.setHit(hit);
    return option;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:23,代码来源:CompletionSuggestion.java

示例3: createTestItem

import org.elasticsearch.search.SearchHit; //导入方法依赖的package包/类
public static Option createTestItem() {
    Text text = new Text(randomAsciiOfLengthBetween(5, 15));
    int docId = randomInt();
    int numberOfContexts = randomIntBetween(0, 3);
    Map<String, Set<CharSequence>> contexts = new HashMap<>();
    for (int i = 0; i < numberOfContexts; i++) {
        int numberOfValues = randomIntBetween(0, 3);
        Set<CharSequence> values = new HashSet<>();
        for (int v = 0; v < numberOfValues; v++) {
            values.add(randomAsciiOfLengthBetween(5, 15));
        }
        contexts.put(randomAsciiOfLengthBetween(5, 15), values);
    }
    SearchHit hit = null;
    float score = randomFloat();
    if (randomBoolean()) {
        hit = SearchHitTests.createTestItem(false);
        score = hit.getScore();
    }
    Option option = new CompletionSuggestion.Entry.Option(docId, text, score, contexts);
    option.setHit(hit);
    return option;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:24,代码来源:CompletionSuggestionOptionTests.java

示例4: matchesSafely

import org.elasticsearch.search.SearchHit; //导入方法依赖的package包/类
@Override
protected boolean matchesSafely(SearchHit searchHit) {
    return searchHit.getScore() == score;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:5,代码来源:ElasticsearchMatchers.java


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