0

Technology Stack:

  • Tinkerpop Stack 2.4 (Rexster HTTP REST Server)
  • Titan 0.5.4
  • DynamoDB (AWS)
  • NodeJS

Goal:

I would like to utilize the Rexster RESTful based API for querying and traversals of my graph database. I am trying to understand the _properties query parameter for filtering results based on Vertex Query syntax.

Result of Vertices Query:

http://localhost:8182/graphs/mygraph/vertices { "version": "2.5.0", "results": [ { "name": "Frank Stein", "_id": 25600768, "_type": "vertex" }, { "name": "John Doe", "_id": 25600512, "_type": "vertex" } ], "totalSize": 2, "queryTime": 219.86688 }

Result of Edge Query:

http://localhost:8182/graphs/mygraph/vertices

{ "version": "2.5.0", "results": [ { "_id": "f8q68-f8phc-4is5-f8pog", "_type": "edge", "_outV": 25600512, "_inV": 25600768, "_label": "friends" } ], "totalSize": 1, "queryTime": 164.384768 }

Problem:

These URI's do not return what I am assuming I would get returned, always return an empty set.:

Requests:

_http://localhost:8182/graphs/privvy/vertices/25600768/both?properties=[[name,=,"John Doe"]] _http://localhost:8182/graphs/privvy/vertices/25600768/both?properties=[[name,=,John Doe]] _http://localhost:8182/graphs/privvy/vertices/25600768/both?properties=[[name,=,(s,"John Doe")]] _http://localhost:8182/graphs/privvy/vertices/25600768/both?properties=[[name,=,(s,John Doe)]]

Response:

{ "version": "2.5.0", "results": [], "totalSize": 0, "queryTime": 22.641152 }

Additional Information:

The following URI does return a resulting set of adjacent vertices if I just switch the = (equal operator) to the <> (not equal) operator:

Request:

_http://localhost:8182/graphs/privvy/vertices/25600768/both?properties=[[name,<>,"John Doe"]]

Response:

{ "version": "2.5.0", "results": [ { "name": "John Doe", "_id": 25600512, "_type": "vertex" } ], "totalSize": 1, "queryTime": 17.451008 }

Anyone have any clue where I may be going wrong?

References:

Thanks Friends!

Tom

Tom Pennetta
  • 482
  • 7
  • 25

1 Answers1

1

In the link you provided, note this section explicitly:

https://github.com/tinkerpop/blueprints/wiki/Vertex-Query#query-use-cases

Note that all the use cases involved "edges". You are trying to do a vertex query over property values on the adjacent vertex of an edge. If you want your query to work that way, you would have to denormalize your data to include the "name" property on the edges.

Note that in my curl request against the default graph below, things work as expected when I build my vertex query against "weight" (and edge property):

$ curl -g "http://localhost:8182/graphs/tinkergraph/vertices/1/out?_properties=[[weight,=,(f,0.4)]]"
{"version":"2.5.0","results":[{"name":"lop","lang":"java","_id":"3","_type":"vertex"}],"totalSize":1,"queryTime":1.070072}
stephen mallette
  • 45,298
  • 5
  • 67
  • 135
  • Thanks for this information. From what you have pointed out it makes sense that the use cases for a Vertex Query may be based on the edge traversals and filtering, however, I find it hard to believe I would need to de-normalize a vertex's properties into an edge to accomplish the goal I am trying to do. Defeats the purpose of the DB/Graph system entirely. I need to find a way to filter queries on the vertex properties, perhaps I need to look into vertex keys for this technology stack. – Tom Pennetta Dec 07 '15 at 16:08
  • Unless your graph has some norm where you have millions of edges per vertex, denormalization probably isn't something to consider. You can filter in the manner you describe in your question (i.e. by vertex properties) pretty easily with Gremlin, you just can't do it with the standard REST API that Rexster exposes. So, if you need to do that, I'd just use Rexster's Gremlin Extension. btw, note that Rexter is no longer under development - see Gremlin Server for TinkerPop 3 if you are just getting started: http://tinkerpop.apache.org/docs/3.1.0-incubating/#gremlin-server – stephen mallette Dec 07 '15 at 18:41
  • And now, you can use TP3 and Titan 1.0.0 with DynamoDB: https://github.com/awslabs/dynamodb-titan-storage-backend – Alexander Patrikalakis Dec 14 '15 at 18:16