本文整理匯總了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();
}
示例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;
}
示例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;
}
示例4: matchesSafely
import org.elasticsearch.search.SearchHit; //導入方法依賴的package包/類
@Override
protected boolean matchesSafely(SearchHit searchHit) {
return searchHit.getScore() == score;
}