© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
Apache TinkerPopAT
Apache TinkerPop•6mo ago•
15 replies
eternallaw

Help with a gremlin query..

Hi folks,

I have a graph where:

Customer vertices connect to Order vertices via hasOrder edges.

Each Customer has a customerId

Each Order has:
• orderId
• orderDate

Rules for output:

•I will pass multiple customer IDs as input.

•For each customer, fetch their orders.

•A customer may have multiple entries for the same orderId. In that case:
Keep only the one with the latest orderDate.

The selection of orders for one customer must not interfere with another customer’s selection — even if they share the same orderId.

I cannot use group() or any other grouping/aggregation step — only order(), limit(), dedup(), etc.

Example scenario:

customerId | orderId | orderDate
C1 | O1 | 2024-01-01
C1 | O1 | 2024-01-02
C1 | O2 | 2024-01-03
C2 | O1 | 2024-01-01
C2 | O1 | 2024-01-02
C2 | O3 | 2024-01-04
C3 | O4 | 2024-01-02


Expected output:


{c=C1, o={orderId=[O1], orderDate=[2024-01-02]}}
{c=C1, o={orderId=[O2], orderDate=[2024-01-03]}}
{c=C2, o={orderId=[O1], orderDate=[2024-01-02]}}
{c=C2, o={orderId=[O3], orderDate=[2024-01-04]}}
{c=C3, o={orderId=[O4], orderDate=[2024-01-02]}}


Need help: How can I write a Gremlin query that achieves this with only order(), limit(), and dedup(), without using group() or similar, while ensuring that each customer is processed independently?

QUERY TO SAMPLE DATA IN CHATS..
Apache TinkerPop banner
Apache TinkerPopJoin
Apache TinkerPop is an open source graph computing framework and the home of the Gremlin graph query language.
1,376Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

Gremlin Query timeout issue
Apache TinkerPopATApache TinkerPop / questions
12mo ago
Need help to implement a generic gremlin query with Apache thinkerPop Java.
Apache TinkerPopATApache TinkerPop / questions
3y ago
Query if else in gremlin
Apache TinkerPopATApache TinkerPop / questions
3y ago
How to speed up gremlin query
Apache TinkerPopATApache TinkerPop / questions
2y ago