highlight_query
突出显示搜索查询之外的其他查询的匹配项
rescore_query
重新打分
QueryRescorerBuilder rescorerBuilder = new QueryRescorerBuilder(QueryBuilders.matchPhraseQuery("search", keyword));
rescorerBuilder.setQueryWeight(0.7f);
rescorerBuilder.setRescoreQueryWeight(1.2f);
searchSourceBuilder.addRescorer(rescorerBuilder);
举例
{
"query": {
"match": {
"comment": {
"query": "foo bar"
}
}
},
"rescore": {
"window_size": 50,
"query": {
"rescore_query": {
"match_phrase": {
"comment": {
"query": "foo bar",
"slop": 1
}
}
},
"rescore_query_weight": 10
}
},
"_source": false,
"highlight": {
"order": "score",
"fields": {
"comment": {
"fragment_size": 150,
"number_of_fragments": 3,
"highlight_query": {
"bool": {
"must": {
"match": {
"comment": {
"query": "foo bar"
}
}
},
"should": {
"match_phrase": {
"comment": {
"query": "foo bar",
"slop": 1,
"boost": 10.0
}
}
},
"minimum_should_match": 0
}
}
}
}
}
}