怎么又是你

nested 查询排序结果异常

Elasticsearch | 作者 胡萝卜超甜 | 发布于2018年10月17日 | 阅读数:2015

es索引中的对象mapping中nested字段如下
"cates": {
"type": "nested",
"properties": {
"categoryEn": {
"type": "text",
"fields": {
"keyword": {
"ignore_above": 256,
"type": "keyword"
}
}
},
"cateSort": {
"type": "long"
}
}
对应的查询请求如下
{
"query": {
"bool": {
"must": [
{
"nested": {
"path": "cates",
"query": {
"bool": {
"must": [
{
"match": {
"cates.categoryEn": "LOCAL"
}
}
]
}
}
}
}
]
}
},
"sort": {
"cates.cateSort": {
"order": "asc",
"nested_filter": {
"term": {
"categoryEn": "LOCAL"
}
}
}
},
"_source": {
"includes": [
"cates",
"id"
],
"excludes": []
}
}
 
响应结果如下:
{
"took": 1,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"skipped": 0,
"failed": 0
},
"hits": {
"total": 4,
"max_score": null,
"hits": [
{
"_index": "ghyx_combine_index",
"_type": "ghyx_combine_type",
"_id": "5",
"_score": null,
"_source": {
"cates": [
{
"categoryEn": "LOCAL",
"cateSort": 1
}
],
"id": "5"
},
"sort": [
9223372036854776000
]
},
{
"_index": "ghyx_combine_index",
"_type": "ghyx_combine_type",
"_id": "4",
"_score": null,
"_source": {
"cates": [
{
"categoryEn": "LOCAL",
"cateSort": 7
}
],
"id": "4"
},
"sort": [
9223372036854776000
]
},
{
"_index": "ghyx_combine_index",
"_type": "ghyx_combine_type",
"_id": "7",
"_score": null,
"_source": {
"cates": [
{
"categoryEn": "FIRST",
"cateSort": 6
},
{
"categoryEn": "LOCAL",
"cateSort": 8
}
],
"id": "7"
},
"sort": [
9223372036854776000
]
},
{
"_index": "ghyx_combine_index",
"_type": "ghyx_combine_type",
"_id": "3",
"_score": null,
"_source": {
"cates": [
{
"categoryEn": "LOCAL",
"cateSort": 3
}
],
"id": "3"
},
"sort": [
9223372036854776000
]
}
]
}
}
这个结果和预想中的 根据cates.cateSort排序,且参与的cates满足cates.categoryEn='LOCAL'不符
请问这个问题出在哪?

 
已邀请:

要回复问题请先登录注册