aql

define geo index in ArangoDB

倖福魔咒の 提交于 2019-12-11 12:15:52
问题 I have a data structure like below. how can I define a geo index for that structure? { "currentGeoLocation": { "latitude": -10, "longitude": 1 } } I tried these command: 1- db.test.ensureIndex({ type: "geo", fields: [ "currentGeoLocation[latitude]","currentGeoLocation[longitude]" ] }); 2- db.test.ensureIndex({ type: "geo", fields: [ "currentGeoLocation.latitude","currentGeoLocation.longitude" ] }); but I think none works correctly. because after I search the nearest items, I got []. whats the

How to merge all results of AQL into single document with custom properties

爱⌒轻易说出口 提交于 2019-12-11 03:37:46
问题 I have an AQL query traversing graph that always should return a fixed amount of documents from a unique set of collections. So each collection will occur only once and with one document only. I wish to merge them all into a single document under properties that reflects document’s collection name. Query as simple as: FOR v IN ANY "vertex/key" edge_collection RETURN v Returns a sample result as: [ { "_key": "123", "_id": "foo/123", "_rev": "_WYhh0ji---", "foo_attribute": "lorem impsum" }, { "

How to solve Arango query promise error? [duplicate]

偶尔善良 提交于 2019-12-10 23:04:55
问题 This question already exists : AQL Query returns a Promise Closed last year . I have been trying to get a query result from Arangodb in to my front end service (Angular 4) using soap message. I am able to get a result of the query but printed out in console.log. But how can I get it under this function (Service). So that I can feed into the soap message: var soap_msg = '<soapenv:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns

INTERSECTION of (n) arrays in ArangoDB AQL

爷,独闯天下 提交于 2019-12-05 18:35:05
The scenario is this: I have an ArangoDB collection containing items, and another collection containing tags. I am using a graph, and I have an edge collection called "Contains" connecting the items and tags. An item has multiple tags. Now I am trying to do a search for items containing multiple tags. E.g. items containing the tags "photography", "portrait" and "faces". My general approach is to start a graph traversal from each of the tag vertices and find the items that relate to that tag. That part works fine. I get a list of items. But the last part of my task is to make an intersection of

AQL Query returns a Promise

≡放荡痞女 提交于 2019-12-04 06:11:27
问题 I have been trying to get a query result from Arangodb in to my front end service(Angular 4) using soap message. I am able to get a result of the query but printed out in console.log. But how can I get it under this function(myService). In other words, How can I feed my query result into a function rather than printing out the result in console. So that I can use this function to get the output of the query? I have used .then() as well in order to get the promise.What am I still missing in it

What is the fastest ArangoDB friends-of-friends query (with count)

痴心易碎 提交于 2019-12-03 15:20:45
问题 I'm trying to use ArangoDB to get a list of friends-of-friends. Not just a basic friends-of-friends list, I also want to know how many friends the user and the friend-of-a-friend have in common and sort the result. After several attempts at (re)writing the best performing AQL query, this is what I ended up with: LET friends = ( FOR f IN GRAPH_NEIGHBORS('graph', @user, {"direction": "any", "includeData": true, "edgeExamples": { name: "FRIENDS_WITH"}}) RETURN f._id ) LET foafs = (FOR friend IN

What is the fastest ArangoDB friends-of-friends query (with count)

[亡魂溺海] 提交于 2019-12-03 05:00:39
I'm trying to use ArangoDB to get a list of friends-of-friends. Not just a basic friends-of-friends list, I also want to know how many friends the user and the friend-of-a-friend have in common and sort the result. After several attempts at (re)writing the best performing AQL query, this is what I ended up with: LET friends = ( FOR f IN GRAPH_NEIGHBORS('graph', @user, {"direction": "any", "includeData": true, "edgeExamples": { name: "FRIENDS_WITH"}}) RETURN f._id ) LET foafs = (FOR friend IN friends FOR foaf in GRAPH_NEIGHBORS('graph', friend, {"direction": "any", "includeData": true,

AQL template in arango Foxx does not work correctly with array

匿名 (未验证) 提交于 2019-12-03 01:41:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: The below query would not work if I used an array but work normally if we use a string to construct the snippet. Did I make a mistake somewhere or is this one is a bug related to arango? var array=["1","2"] //Make a snippet depend on array. var snippet=aql.literal(`FILTER u.id IN "${array}"`) //Main query. Result is incorrect even though it runs var query=db._query(aql` For u in Collection {$snippet} RETURN u ` ) Example of the correct query using string var string="1" var snippet=aql.literal(`FILTER u.id == "${array}"`) 回答1: FILTER u.id IN

ArangoDB : How to get all the possible paths between 2 vertices?

旧时模样 提交于 2019-12-02 05:36:12
问题 How to get all the possible paths between 2 vertices (eg. X and Y) with maxDepth = 2? I tried with TRAVERSAL but it is taking around 10 seconds to execute. Here is the query : FOR p IN TRAVERSAL(locations, connections, "X", "outbound", { minDepth: 1, maxDepth: 2, paths: true }) FILTER p.destination._key == "Y" RETURN p.path.vertices[*].name The locations (vertices) collection has 23753 documents, and the connections (edges) collection has 123414 documents. 回答1: You can speed up the query a

Arangodb AQL recursive graph traversal

不想你离开。 提交于 2019-12-02 00:50:30
I have a graph with three collections which items can be connected by edges. ItemA is a parent of itemB which in turn is a parent of itemC. Elements only can be connected by edges in direction "_from : child, _to : parent" Currently I can get only "linear" result with this AQL query: LET contains = (FOR v IN 1..? INBOUND 'collectionA/itemA' GRAPH 'myGraph' RETURN v) RETURN { "root": { "id": "ItemA", "contains": contains } } And result looks like this: "root": { "id": "itemA", "contains": [ { "id": "itemB" }, { "id": "itemC" } ] } But I need to get a "hierarchical" result of graph traversal