Reputation: 497
i use the arangodb tinkerpop provider (https://github.com/ArangoDB-Community/arangodb-tinkerpop-provider) and create a vertex like this:
graph = GraphFactory.open(conf);
GraphTraversalSource g = gts.clone();
UUID userId1 = UUID.randomUUID();
Vertex vertex1 = graph.addVertex("person");
vertex1.property("uid", userId1);
Everything works fine and i see that i can found my starting vertex with this gremlin query:
System.out.println(g.V().has("uid", userId1).properties().toList());
Now, i've two questions:
1) Are all vertex properties searchable via an index or can i create an index especially for this property ?
2) inside the collections (Web UI from ArangoDb) i didn't see my properties - to see the properties, i need to look into *_ELEMENT-PROPERTIES - is there an other possibility to see the properties inside the collections view ?
Thanks for you help. Marcel
Upvotes: 0
Views: 251
Reputation: 717
I will answer question 2 first as this will help me address question 1.
2) Conceptually, the Tinkerpop API considers vertex properties (and vertex properties' properties) as graph vertices. As a result, the API expects vertex properties to behave like vertices and the navigation from a vertex to each of its properties to mimic that of two vertices connected by and edge:
v1 ---> uuid
where the uuid vertex would hold the uuid value. For this reason, the current implementation does NOT store the vertex properties in the vertex's document, but in a separate document (in the *_ELEMENT-PROPERTIES collection). The main drive for this approach is that it simplified the implementation a lot. One of the drawbacks is that, as you mentioned, looking at the properties of a vertex in the UI is not straight forward: you would need a query, instead of just opening a the vertex's document. BTW, the query you can use for this is:
WITH @@vertexlabel
FOR v, e
IN OUTBOUND @startrVertexID
@@propertiesEdge
RETURN {"name": v.key, "value": v.value}
where you can provide the desired vertex label/collection, the vertex of interest ID and the appropriate propertiesEdge collection name (i.e. *_ELEMENT-PROPERTIES).
1) The current implementation does not allow providing indexes for specific attributes since properties are stored as documents and hence we can not use them as indices. As camba1 mentioned, ArangoDB automatically indexes _key in documents so you can use custom key values if you want to make sure searches based on a specific attribute are index based. Custom _key values are used by providing custom IDs. Note that the arangodb-tinkerpop-provider only supports custom vertex/edge/property IDs of type string (with some caveats). Thus, in your case you could use the UUID as the vertex's ID:
graph = GraphFactory.open(conf);
GraphTraversalSource g = gts.clone();
UUID userId1 = UUID.randomUUID();
Vertex vertex1 = graph.addVertex("person").properties(T.id, userId1.toString());
And then you can find this vertex by ID (which will be indexed);
System.out.println(g.V("*_vertex/" + userId1).properties().toList());
(Note that you need to replace * with our graph name.)
There is currently a bug opened for changing the storage of properties: Issue 38 and I have started work on a possible solution for which you can find details in the bug comments. Please feel free to chip in with any ideas!
Thanks for using the provider!
Upvotes: 3