adaak
adaak

Reputation: 21

How to query titan graph with gremlin queries based on integer properties

I have multiple nodes in a titan graph server with integer properties, I want to query the graph based on integer properties, the server is configured with REST so I'm querying the graph this way:

titan-server:8182/gremlin=Query 
(e.g Query could be : g.V().hasLabel("Person")) 

I want to fetch all person vertices with age = 30 (just an example)

This can be done in gremlin console (socket based) as follow: g.V().hasLabel("Person").has("age",30);

but this doesn't work on rest query, it give an empty results (even if there is such a vertex with age = 30 ):

titan-server:8182/gremlin=g.V().hasLabel("Person")**.has("age",30)**;

I didn't find any docs over the internet for gremlin on rest.

Thank you for help guys

Upvotes: 1

Views: 278

Answers (1)

Filipe Teixeira
Filipe Teixeira

Reputation: 3565

I managed to get the REST API to work by doing the following. First, as specified here make sure to change the channel in the gremlin-server.yaml config to:

channelizer: org.apache.tinkerpop.gremlin.server.channel.HttpChannelizer

Then try the following post:

{ 
    "gremlin" : "g.V().hasLabel(x).has(y,z)",
    "bindings" : 
    {
        "x" : "Person",
        "y" : "age",
        "z" : 30
    }
}

More info on the REST API can be found here

Upvotes: 2

Related Questions