我有一个名为find的索引和一个名为song的类型。歌曲类型结构:
"_index": "find",
"_type": "song",
"_id": "192108",
"_source": {
"id": 192108,
"artist": "Melanie",
"title": "Dark Night",
"lyrics": "Hot air hangs like a dead man\nFrom a white oak tree",
"downloadCount": 234
}因为多首歌曲可能有相同的字段值,所以我需要通过downloadCount这样的流行度字段来提高结果。
如何将以下查询更改为按downloadCount优化?
GET /search/song/_search
{
"query": {
"multi_match": {
"query": "like a dead hangs",
"type": "most_fields",
"fields": ["artist","title","lyrics"],
"operator": "or"
}
}
}发布于 2017-03-12 18:49:47
你可以使用elastic_search的field_value_factor功能,通过downloadCount来提升结果
发布于 2017-03-13 13:29:21
您可以使用function score查询。功能评分查询通过script_score函数提供了根据单据字段对单据进行评分的接口。
{
"query": {
"function_score": {
"query": {
"bool": {
"must": [{
"term": {
"you_filter_field": {
"value": "VALUE"
}
}
}]
}
},
"functions": [{
"script_score": {
"script": "doc['downloadCount'].value"
}
}]
}
}
}谢谢
https://stackoverflow.com/questions/42745848
复制相似问题