我有一张桌子用来做一些活动,比如
[
{
"id": 123,
"name": "Ram",
"status": 1,
"activity": "Poster Design"
},
{
"id": 123,
"name": "Ram",
"status": 1,
"activity": "Poster Design"
},
{
"id": 124,
"name": "Leo",
"categories": [
"A",
"B",
"C"
],
"status": 1,
"activity": "Brochure"
},
{
"id": 134,
"name": "Levin",
"categories": [
"A",
"B",
"C"
],
"status": 1,
"activity": "3D Printing"
}]
我想通过对字段活动进行排序,从elastic search 5.5中获得这些数据,但我需要所有对应于name = "Ram“的数据,然后保留在一个查询中。
发布于 2019-02-27 20:56:08
您可以使用function score查询根据过滤器(本例中的名称为ram )的匹配来提高结果。
下面的查询应该适用于您
POST sort_index/_search
{
"query": {
"function_score": {
"query": {
"match_all": {}
},
"boost": "5",
"functions": [{
"filter": {
"match": {
"name": "ram"
}
},
"random_score": {},
"weight": 1000
}],
"score_mode": "max"
}
},
"sort": [{
"activity.keyword": {
"order": "desc"
}
}]
}https://stackoverflow.com/questions/54904357
复制相似问题