當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。