Bringing together the Apache Cassandra experts from the community and DataStax.

Want to learn? Have a question? Want to share your expertise? You are in the right place!

Not sure where to begin? Getting Started

 

question

ramesh.pallapothu_119946 avatar image
ramesh.pallapothu_119946 asked ·

How do I sort results of a gremlin query by custom values?

Is it possible to order gremlin query results by custom values like below ?

g.V().hasLabel("party")
  .has("party_phone",token("90777777"))
  .and(__.properties("party_phone")
  .has("phone_nbr",eq("90777777")))
  .barrier()
  .dedup()
  .order().by("created_source_id" in ('3531348','4035','1179'))) 

Please let me know if any more details required on this.

Looking for below kind of solution in gremlin

graph
1603998341143.png (20.5 KiB)
1 comment
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.

Jeremy Hanna has notified me that he is contact with your directly to assist you with your questions. Cheers!

0 Likes 0 · ·

1 Answer

jeromatron avatar image
jeromatron answered ·

I spoke with Ramesh a bit about getting general sorting working which wasn't a problem. The problem is with the custom sorting like in his attached example. That is, dynamically putting some results at the top based on the value of certain fields.

We talked about separate queries and doing an application side join, but that's what they're trying to move away from - they're doing that now.

We also talked about having an extra "sorting" or "preferred" field on the data to promote certain rows. However the sorting has to be dynamic based on the query so that extra field idea wouldn't work.

Having talked to a friend in the TinkerPop community, one thought would be to just execute the different queries within the same traversal and union them together. That way, you still have relatively straightforward logic for each and you're able to execute them server side to get the desired ordering of results. Would that work for you Ramesh?

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.