Programmatically creating edges in ArangoDB

微笑、不失礼 提交于 2019-12-06 05:11:34

A single AQL query should suffice:

FOR p IN people
    FOR e IN emails
        FILTER p.email == e.from
        INSERT {_from: p._id, _to: e._id} INTO sent

The email addresses in the vertex collection people are matched with the from email addresses of the emails vertex collection. For every match, a new edge is inserted into an edge collection sent, linking people and email records.

If both vertex collections contain a small number of documents, it is okay to execute this query without indexes (e.g. 1,000 persons and 3,000 emails took about 2 seconds in my test). For larger datasets, make sure to create a hash index in people on the email attribute, and in emails a hash index on from. It reduced the execution time to about 30ms in my test.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!