本文整理汇总了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;
}