我想按照一些提升规则对我的查询结果进行排序,同时我希望它们尽可能按创建日期排序,如果我添加一个 created_at 排序,它会改变一切,我的结果不再相关。所以我想这样做的唯一方法是提升 created_at 字段(最新的在计算该提升的分数方面具有最大的奖励)但我不知道如何实现它。这是我的查询:
query = {
"query" : {
"bool" : {
"must" : [
{
"range" : {
"deadline" : {
"gte" : "2016-05-30T11:39:10+02:00"
}
}
},
{
"terms" : {
"state" : [
"open"
]
}
},
{
"query_string" : {
"query" : "chant",
"default_operator" : "AND",
"analyzer" : "search_francais",
"fields" : [
"title^6",
"description",
"brand",
"category_name"
]
}
}
]
}
},
"filter" : {
"and" : [
{
"geo_distance" : {
"distance" : "40km",
"location" : {
"lat" : 48.855736,
"lon" : 2.32927300000006
}
}
}
]
},
"sort" : [
{
"_score" : "desc"
},
#{
# "created_at" : "desc" ==> i tried this but it doesnt change results
#}
]
}