【发布时间】:2016-01-19 19:10:35
【问题描述】:
我已将数据存储在 ArangoDB 2.7.1 中,集合名称为 DSP:
{"content": "Book.xml", "type": "string", "name": "name", "key": 102}
{"content": "D:/XMLexample/Book.xml", "type": "string", "name": "location", "key": 102}
{"content": "xml", "type": "string", "name": "mime-type", "key": 102}
{"content": 4130, "type": "string", "name": "size", "key": 102}
{"content": "Sun Aug 25 07:53:32 2013", "type": "string", "name": "created_date", "key": 102}
{"content": "Wed Jan 23 09:14:07 2013", "type": "string", "name": "modified_date", "key": 102}
{"content": "catalog", "type": "tag", "name": "root", "key": 102}
{"content": "book", "type": "string", "name": "tag", "key": 103}
{"content": "bk101", "type": {"py/type": "__builtin__.str"}, "name": "id", "key": 103}
{"content": "Gambardella, Matthew", "type": {"py/type": "__builtin__.str"}, "name": "author", "key": 1031}
{"content": "XML Developer's Guide", "type": {"py/type": "__builtin__.str"}, "name": "title", "key": 1031}
{"content": "Computer", "type": {"py/type": "__builtin__.str"}, "name": "genre", "key": 1031}
{"content": "44.95", "type": {"py/type": "__builtin__.str"}, "name": "price", "key": 1031}
{"content": "2000-10-01", "type": {"py/type": "__builtin__.str"}, "name": "publish_date", "key": 1031}
{"content": "An in-depth look at creating applications with XML.", "type": {"py/type": "__builtin__.str"}, "name": "description", "key": 1031}
这里,单个集合{"content": "Book.xml", "type": "string", "name": "name", "key": 102} 表示集合中的单个文档。
现在,我想访问多个文档中 key 属性的相似值或类型为计算机的值标题和价格的所有文档,以获取相同的 key 值。我尝试了 AQL FOR p IN DSP filter p.name == "publish_date" AND p.content == "2000-10-01" AND p.name == 'title' return p 但这会返回一个空集,因为它在单个文档中进行比较,而不是在集合中。
像关系数据库一样,需要某种自联接,但我不知道如何应用自联接。请告诉我如何访问具有相同键属性值的所有文档,其中publish_date 是“2000-10-01”。我希望此查询的结果是以下文档,因为对应于值为 2000-10-01 的 publish_date,key 的值为 1031:
{"content": "Gambardella, Matthew", "type": {"py/type": "__builtin__.str"}, "name": "author", "key": 1031}
{"content": "XML Developer's Guide", "type": {"py/type": "__builtin__.str"}, "name": "title", "key": 1031}
{"content": "Computer", "type": {"py/type": "__builtin__.str"}, "name": "genre", "key": 1031}
{"content": "44.95", "type": {"py/type": "__builtin__.str"}, "name": "price", "key": 1031}
{"content": "2000-10-01", "type": {"py/type": "__builtin__.str"}, "name": "publish_date", "key": 1031}
{"content": "An in-depth look at creating applications with XML.", "type": {"py/type": "__builtin__.str"}, "name": "description", "key": 1031}
【问题讨论】: