Max
Max
Explore posts from servers
ATApache TinkerPop
Created by Max on 9/3/2024 in #questions
Gremlin query to order vertices with some locked to specific positions
I'm working with a product catalog in a graph database using Gremlin. The graph structure includes: 1. Product vertices 2. Category vertices 3. belongsTo edges connecting products to categories. The edge can have an optional lockedPosition property as integer. I need to create a query that returns products in a specific order, where: 1. Some products are "locked" to specific positions (stored as a lockedPosition property on the belongsTo edge) 2. Other "unlocked" products should fill in around these fixed positions For example, if I have 20 products in a category, and product A is locked to position 3 and product B to position 7, the result should return these products in those exact positions, with other products filling the remaining slots with whatever sorting order. (this "product pinning/locking" functionality is used by merchandising team to manually re-arrange products on a product listing page). Can anyone suggest a Gremlin query to achieve this? Also, maybe my data model is wrong for this use case, so I am also keen to accept other suggestions to represent this use case. Thank you!
17 replies