首页 > 解决方案 > Elastic Search :: 按日期排序,得分较高的文档

问题描述

我想知道如何在不实际对 multi_match 查询进行排序的情况下增加较新文档的概率(基于 publishedDate 值):

 {
 "from": 0,
 "size": 12,
 "_source": false,
 "query": {
   "bool": {
     "must": [
       {
         "multi_match": {
           "query": "Best Movies",
           "fields": [
             "publishedDate^1",
             "headline^2",
             "subheadline^3",
             "metaDescription^4",
             "metaTitle"
           ],
           "type": "best_fields",
           "lenient": true,
           "tie_breaker": 0.3
         }
       }
     ],
     "filter": {
       "bool": {
         "must": [
           {
             "term": {
               "status.keyword": "published"
             }
           },
           {
             "term": {
               "taxonomyPaths.verticals.keyword": "primaryvertical"
             }
           }
         ]
       }
     }
   }
 }
}

如果我添加会发生什么:

"sort": [
    {
      "publishedDate": {
        "order": "desc"
      }
    }
  ]

它完全丢失了实际得分较高的文档。如何获得具有更高分值的文档,但将较新的条目“publishedDate”堆叠在结果之上?

标签: sortingelasticsearchsearch

解决方案


推荐阅读