使用python和AQL,我试图返回与给定列表中任何项匹配的顶点列表。我正在获得的db的当前结果是一个空列表。
python的等价物是:
list_of_terms = ["yellow", "blue"]
list_of_vertices = ["yellow", "green"]
terms = [term for term in list_of_terms if term in list_of_vertices]
print(terms)一个我尝试过的AQL查询的例子。
For doc in some_collection
FILTER doc.name==@list_of_terms
RETURN doc以及使用python-arango实现的全部功能
bind_vars = {
"lookup_terms": list_of_terms
} 提前感谢
qry = "FOR doc IN `{0}` FILTER doc.name== @lookup_terms AND doc.text != null RETURN doc".format(collection_nm)
print(qry)
cursor = db.aql.execute(
qry,
bind_vars=bind_vars,
batch_size=10,
count=True
)发布于 2020-08-06 09:58:39
您应该使用IN操作符:
FOR doc IN some_collection
FILTER doc.name IN @list_of_terms
RETURN doc从文件中:
IN:测试一个值是否包含在数组中
请参阅https://www.arangodb.com/docs/stable/aql/operators.html#range-operator
然后,您的python代码将变成:
bind_vars = {
"lookup_terms": list_of_terms
}
qry = "FOR doc IN `{0}` FILTER doc.name IN @lookup_terms AND doc.text != null RETURN doc".format(collection_nm)
print(qry)
cursor = db.aql.execute(
qry,
bind_vars=bind_vars,
batch_size=10,
count=True
)https://stackoverflow.com/questions/63256722
复制相似问题