我一条记录里面有两个字段,userId,collectionRank,其中collectionRank里面包含两个嵌入字段:collectionId和pv。 例如这种:
{
"_index": "user_collection_stats",
"_type": "_doc",
"_id": "821788819",
"_score": 1,
"_source": {
"userid": 821788819,
"collectionRank": [
{
"collectionid": "4006653",
"pv": 8
},
{
"collectionid": "3836102",
"pv": 11
},
{
"collectionid": "3631489",
"pv": 5
}
]
}
}
我现在想通过查询语句,得到每个用户,关注的合集中按pv排好序(降序)的合集ID,怎样写查询语句呢,试了一些写法得到的都是无序的。
期待的结果如下:
{
"_index": "user_collection_stats",
"_type": "_doc",
"_id": "821788819",
"_score": 1,
"_source": {
"userid": 821788819,
"collectionRank": [
{
"collectionid": "3836102",
"pv": 11
},
{
"collectionid": "4006653",
"pv": 8
},
{
"collectionid": "3631489",
"pv": 5
}
]
}
}
跪求各位大佬指点,多谢
{
"_index": "user_collection_stats",
"_type": "_doc",
"_id": "821788819",
"_score": 1,
"_source": {
"userid": 821788819,
"collectionRank": [
{
"collectionid": "4006653",
"pv": 8
},
{
"collectionid": "3836102",
"pv": 11
},
{
"collectionid": "3631489",
"pv": 5
}
]
}
}
我现在想通过查询语句,得到每个用户,关注的合集中按pv排好序(降序)的合集ID,怎样写查询语句呢,试了一些写法得到的都是无序的。
期待的结果如下:
{
"_index": "user_collection_stats",
"_type": "_doc",
"_id": "821788819",
"_score": 1,
"_source": {
"userid": 821788819,
"collectionRank": [
{
"collectionid": "3836102",
"pv": 11
},
{
"collectionid": "4006653",
"pv": 8
},
{
"collectionid": "3631489",
"pv": 5
}
]
}
}
跪求各位大佬指点,多谢
1 个回复
森 - Elasticsearch,php
赞同来自:
查询条件:
返回的结果
希望对你有帮助