Search code examples
javascriptgremlinjanusgraphgremlin-server

Creating and querying Geopoint in JanusGraph using Gremlin JavaScript


I can't find a way to create a vertex that holds a Geopoint using the gremlin JavaScript client (3.4.2).

The schema defined for the property is the following:

geopoint=mgmt.makePropertyKey('geopoint').dataType(Geoshape.class).cardinality(org.janusgraph.core.Cardinality.SINGLE).make();

Reading the documentation from JanusGraph I should be able to do something like this, both for querying and creating:

g.addV('location').property('geopoint', Geoshape.point(45.944, 18.485));

The problem is that I cannot find that 'Geoshape' type anywhere using the gremlin client. I've also tried to use as property value a GeoJSON and an object like '{lat: 45.848, lng: 16.487}' but neither of them worked.

Which is the way to create and query a Geoshape.point for JanusGraph using JavaScript?


Solution

  • As Geoshape is a feature of JanusGraph, TinkerPop (and thus Gremlin) do not natively support such a feature. You would have to rely on JanusGraph to provide that functionality and as of right now I don't think that they provide a Javascript extension for doing so. Just as an example though, you can see that such support is provided in their .NET library.

    Your only workaround at this time for doing Geoshape based queries in Javascript is to submit scripts to Gremlin Server which gives you access to the Geoshape Java class on the server.