PLANNED MAINTENANCE

Hello, DataStax Community!

We want to make you aware of a few operational updates which will be carried out on the site. We are working hard to streamline the login process to integrate with other DataStax resources. As such, you will soon be prompted to update your password. Please note that your username will remain the same.

As we work to improve your user experience, please be aware that login to the DataStax Community will be unavailable for a few hours on:

  • Wednesday, July 15 16:00 PDT | 19:00 EDT | 20:00 BRT
  • Thursday, July 16 00:00 BST | 01:00 CEST | 04:30 IST | 07:00 CST | 09:00 AEST

For more info, check out the FAQ page. Thank you for being a valued member of our community.


question

raktim.0526_188212 avatar image
raktim.0526_188212 asked ·

How do I sort a list of geo points in descending order?

I have followed the Geo-Traversal documentation(DSE 6.7) and was able to find all the cities (points) within a radius from a particular location,

g.V().
has('location', 'point', Geo.inside(Geo.point(2.352222, 48.856614), 300, Geo.Unit.KILOMETERS)).
values('name')

But I am unable to sort them by distance from the centerpoint,

g.V().has('place', 'location', Geo.inside(Geo.point(74.0,40.5),50,Geo.Unit.DEGREES)).
order().by{it.value('location').getOgcGeometry().distance(Geo.point(2.352222, 48.856614).getOgcGeometry())}

This is the link to the documentation, https://docs.datastax.com/en/dse/6.7/dse-dev/datastax_enterprise/graph/using/queryGeospatial.html

Can anyone please help me figure out this gremlin query?

dsegraph
10 |1000 characters needed characters left characters exceeded

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

1 Answer

bettina.swynnerton avatar image
bettina.swynnerton answered ·

Hi,

in order to execute this traversal, you will need to enable lambdas. Lambdas are restricted by default, as they are not recommended for production use.

To get the example to work, you will need to change the graph schema config with these two commands:

Enable development mode:

schema.config().option('graph.schema_mode').set('Development')

Enable lambdas:

schema.config().option('graph.traversal_sources.g.restrict_lambda').set('FALSE')

Schema mode Development is only for development, as the name implies, and is not suitable for production, so I recommend not to rely on this mode for your traversals.

I hope this helps!

3 comments Share
10 |1000 characters needed characters left characters exceeded

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

@bettina.swynnerton Thank you for your response.


After i enable Development and lambdas, it is throwing this error,

Sandbox disallows class com.datastax.shaded.esri.ogc.OGCPoint. Add class com.datastax.shaded.esri.ogc.OGCPoint to whitelist_types in dse.yaml to allow.

Does it require me to change something in the DSE.yaml and restart the nodes? This is the whitelist_types from my DSE.yaml

#         scriptEngines:
#            gremlin-groovy:
#                 config:
#                     # To disable the gremlin groovy sandbox entirely
#                     sandbox_enabled: false
#                     sandbox_rules:
#
#                         # To completely whitelist a package add the package name here
#                         whitelist_packages:
#                         - package.name
#
#                         # To whitelist an individual type add the name of the type here
#                         whitelist_types:
#                         - fully.qualified.class.name
0 Likes 0 · ·

In my case I did not have to make any new changes to the sandbox, but I might have some changes from other tests. Can you confirm your DSE version? I used DSE 6.7.7.

If this is strictly for development, you can of course also disable the sandbox (you will need to do this on all nodes, and you will need to restart your nodes after changes to the dse.yaml)

I come back to the warnings - all these changes are really only for development use, so revert all these changes once you fully explored the example.

To disable the sandbox, append the following after the last commented block in the dse.yaml (this is a yaml, so spacing is important):

graph:
  gremlin_server:
    scriptEngines:
      gremlin-groovy:
        config:
          sandbox_enabled: false

Again, not for production use :)

0 Likes 0 · ·
raktim.0526_188212 avatar image raktim.0526_188212 bettina.swynnerton ♦♦ ·

@bettina.swynnerton thank you. I am currently using 6.7.7 too.

0 Likes 0 · ·