0

我正在尝试以下查询:

gV(835776).out('Follow').in('WallPost').order().by('PostedTimeLong', decr).range(0,2)

我得到以下回应:

{

"requestId": "524462bc-5e46-40bf-aafd-64d00351dc87",
"status": {
    "message": "",
    "code": 200,
    "attributes": { }
},
"result": {
    "data": [
        {
            "id": 1745112,
            "label": "Post",
            "type": "vertex",
            "properties": {
                "PostImage": [
                    {
                        "id": "sd97-11ejc-2wat",
                        "value": ""
                    }
                ],
                "PostedByUser": [
                    {
                        "id": "sc2j-11ejc-2txh",
                        "value": "orbitpage@gmail.com"
                    }
                ],
                "PostedTime": [
                    {
                        "id": "scgr-11ejc-2upx",
                        "value": "2016-06-19T09:17:27.6791521Z"
                    }
                ],
                "PostMessage": [
                    {
                        "id": "sbob-11ejc-2t51",
                        "value": "Hello @[tag:Urnotice_Profile|835776|1]   , @[tag:Abhinav_Srivastava|872488|1]  and @[tag:Rituraj_Rathore|839840|1]"
                    }
                ],
                "PostedTimeLong": [
                    {
                        "id": "scuz-11ejc-2vid",
                        "value": 636019246476802029
                    }
                ]
            }
        },
        {
            "id": 1745112,
            "label": "Post",
            "type": "vertex",
            "properties": {
                "PostImage": [
                    {
                        "id": "sd97-11ejc-2wat",
                        "value": ""
                    }
                ],
                "PostedByUser": [
                    {
                        "id": "sc2j-11ejc-2txh",
                        "value": "orbitpage@gmail.com"
                    }
                ],
                "PostedTime": [
                    {
                        "id": "scgr-11ejc-2upx",
                        "value": "2016-06-19T09:17:27.6791521Z"
                    }
                ],
                "PostMessage": [
                    {
                        "id": "sbob-11ejc-2t51",
                        "value": "Hello @[tag:Urnotice_Profile|835776|1]   , @[tag:Abhinav_Srivastava|872488|1]  and @[tag:Rituraj_Rathore|839840|1]"
                    }
                ],
                "PostedTimeLong": [
                    {
                        "id": "scuz-11ejc-2vid",
                        "value": 636019246476802029
                    }
                ]
            }
        }
    ],
    "meta": { }
}

}

由于同一个帖子发布在两个不同的 ID 上,因此它会出现两次响应。我想根据顶点 id 按响应分组(两者都有相同的顶点 id。或者我只想从它们中取出一个对象,因为两者都是相同的。

我尝试了以下查询,但对我没有任何帮助:

gV(835776).out('Follow').in('WallPost').groupBy{it.id}.order().by('PostedTimeLong', decr).range(0,3)

gV(835776).out('Follow').in('WallPost').group().by(id).order().by('PostedTimeLong', decr).range(0,3)

如何根据顶点 ID 按结果分组。

4

1 回答 1

1

查询

g.V(835776).out('Follow').in('WallPost').group().by(id).order().by('PostedTimeLong', decr).range(0,3)

应该工作,虽然order().by()并且range()不会有任何效果。但是,我不认为你真的想要group(),你更有可能想要dedup()

g.V(835776).out('Follow').in('WallPost').dedup().order().by('PostedTimeLong', decr).limit(3)
于 2016-06-24T12:41:13.553 回答