Search code examples
ibm-cloudgraph-databasesgremlintinkerpop3ibm-graph

Getting an error when I run a V().has() gremlin query against IBM Graph service on bluemix


I created an instance of IBM Graph service on bluemix and created some vertexes. When I try to issue a gremlin query to find one of the vertexes I created, I get an "Internal Error".

Here's the query I'm using

Create the Vertex
curl -u username-password -H 'Content-Type: application/json' -d '{ "label":"movie","properties":{"Name": "Million Dollar Baby","Type": "Movie"} }' -X POST "http://../g/vertices"

Reponse
{"requestId":"07f29cea-25b3-4305-b74b-540466206872","status":{"message":"","code":200,"attributes":{}},"result":{"data":[{"id":8336,"label":"movie","type":"vertex","properties":{"Type":[{"id":"36a-6fk-1l1","value":"Movie"}],"Name":[{"id":"2s2-6fk-sl","value":"Million Dollar Baby"}]}}],"meta":{}}}

Query whether the vertex has a Type property 'movie'
curl -u username-password -H 'Content-Type: application/json' -d '{"gremlin": "def g = graph.traversal(); g.V().has('Type','movie')"}' -X POST "http://../g/gremlin"

Response (Error)
{"code":"InternalError","message":""}


Solution

  • IBM Graph requires users to create indexes for any property that they are going to issue queries against. In this case 'Type' is a property and is included in a gremlin query.

    You need to create an index using the /schema endpoint which is provided by the IBM Graph service in bluemix.

    An example of this is provided in the Service Getting Started guide http://ibm-graph-docs.ng.bluemix.net/gettingstarted.html