I use the following two queries in nGQL to create instances of two tags:
INSERT VERTEX Topic (topicId, first_proposed, approval_status,
followers, tagged_tally) VALUES 9999:("Sample topic id", TIMESTAMP(),
"Pending", 10, 20);
INSERT VERTEX Post(text_added, last_updated, author, postId,
creation_date, shared_total, flagged_total, views, total_likes,
is_a_repost, post_format) VALUES 4444: ("Sample text", timestamp(),
"John Doe", 1234, TIMESTAMP(), 0, 0, 0, 0, false, "some format");
I use the following edge multiple times between the topic instance with VID 9999 and the Post with VID 4444, in which I change the timestamp value, and to do so I repeat the following INSERT EDGE statement:
INSERT EDGE is_tagged (when_tagged) VALUES 4444 -> 9999:(timestamp('2023-06-11T02:18:43'));
I now wish to count the total number of these edge occurrences. The closest I have managed is the following:
GO FROM 4444 OVER is_tagged WHERE $$.Topic.topicId == "Sample topic id" YIELD edge AS e | GROUP BY $-.e YIELD COUNT(*) AS number;
However I wish to reference 9999 and not have to replace the VID for Topic with the property value of Topic_id. How can I do this ? Ideally I want something akin to this:
GO FROM 4444 OVER is_tagged
WHERE VERTEX_ID($$.Topic) == "destination_topic_vid"
or this:
GO FROM 4444 OVER is_tagged
WHERE destination(is_tagged)._dst == 9999
YIELD edge AS e | GROUP BY $-.e YIELD COUNT(*) AS number;
If we know exactly the source and dest VID of the given edge, we could do
FETCHto get the edges between the two, your intuition of specifying VID not prop value is correct.One more thing,
INSERT EDGE is_tagged (when_tagged) VALUES 4444 -> 9999:(timestamp('2023-06-11T02:18:43'));multiple times will not insert multiple instances ofis_taggededges, instead, it updates one edge's prop:when_tagged a couple of times after the first INSERT.One instance of edge in NebulaGraph is (src_id, dst_id, type, rank), where by default, rank is 0 when it's omitted, to enable multiple instances of a given edge per pair of (src, dst), we could put timestamp as RANK field.
Like:
Hope it helps, and welcome to the NebulaGraph community!
BR//Wey
update, regarding the approach to do with
GO, it's underlying do "expand" from start node to all its edges, then filter, thus technically it's a bit of more expensive :).See: