I am facing issues with group() in gremlin

I am trying to find the count of all workspaces group by Customer, and then sorting the response with the count value.

t3 = g.withSideEffect("Neptune#repeatMode","BFS")
.V().has("Project","sid","A68FA527BB214F0E9D2287B455BEFE0A8AACFED0724B407F9EBF727ED439E8ED")
.both().hasLabel("Customer").group().by().by(
both().hasLabel("Workspace").count().order().by(Column.values,Order.desc)
)
.unfold()
.project("rowName","data")
.by(select(Column.keys).properties(MandatoryCustomerAttributes.firstName.name()).value())
.by(select(Column.values))
.by(fold().unfold());

I am facing the following error which I am not able to understand. If someone can help it will be great.

java.util.concurrent.CompletionException: org.apache.tinkerpop.gremlin.driver.exception.ResponseException: {"requestId":"c3246ac6-d306-41e6-a6d1-3adbacb928fb","code":"InvalidParameterException","detailedMessage":"The provided object does not have accessible keys: class java.lang.Long"}
    at java.util.concurrent.CompletableFuture.reportJoin(CompletableFuture.java:375)
    at java.util.concurrent.CompletableFuture.join(CompletableFuture.java:1934)
    at org.apache.tinkerpop.gremlin.driver.ResultSet.one(ResultSet.java:123)
    at org.apache.tinkerpop.gremlin.driver.ResultSet$1.hasNext(ResultSet.java:175)
    at org.apache.tinkerpop.gremlin.driver.ResultSet$1.next(ResultSet.java:182)
    at org.apache.tinkerpop.gremlin.driver.ResultSet$1.next(ResultSet.java:169)
    at org.apache.tinkerpop.gremlin.driver.remote.DriverRemoteTraversal$TraverserIterator.next(DriverRemoteTraversal.java:146)
    at org.apache.tinkerpop.gremlin.driver.remote.DriverRemoteTraversal$TraverserIterator.next(DriverRemoteTraversal.java:131)
    at org.apache.tinkerpop.gremlin.driver.remote.DriverRemoteTraversal.nextTraverser(DriverRemoteTraversal.java:112)
    at org.apache.tinkerpop.gremlin.process.remote.traversal.step.map.RemoteStep.processNextStart(RemoteStep.java:80)
    at org.apache.tinkerpop.gremlin.process.traversal.step.util.AbstractStep.next(AbstractStep.java:129)
    at org.apache.tinkerpop.gremlin.process.traversal.step.util.AbstractStep.next(AbstractStep.java:39)
    at org.apache.tinkerpop.gremlin.process.traversal.util.DefaultTraversal.next(DefaultTraversal.java:204)
    at org.apache.tinkerpop.gremlin.process.traversal.Traversal.forEachRemaining(Traversal.java:278)
    at com.callcomm.eserve.enitty.trial.NeptuneTrialCode.main(NeptuneTrialCode.java:373)

Upvotes: 1

Views: 214

Answers (1)

Kelvin Lawrence
Kelvin Lawrence

Reputation: 14371

Ok I think after staring at this for a while I spotted the issue.

This part of the query

hasLabel("Workspace").count().order().by(Column.values,Order.desc

Is going to try to apply Column.values against the count result (an integer, not a map) - hence the error message.

You will need to order the group after it is created. Here is a simple example, note the use of local.

 g.V('44','3','8').
   group().
     by().
     by(out().count()).
   order(local).
     by(values,desc)

==>[v[8]:251,v[3]:93,v[44]:4]   

As a side note, I did notice that the project only has only 2 items declared but has 3 by modulators. That should not be a problem but you may not be getting the results you wanted.

Upvotes: 2

Related Questions