resttitangremlintinkerpoptinkerpop-blueprint

Tinkerpop Stack Rexster REST API _properties


Technology Stack:

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


Solution

  • 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}