I have a dataset with products and orders. For a given product (here PRODUCT 2) I want to find the 5 products that were ordered most in combination with PRODUCT 2.
I have managed to query and sort all associated products with their frequency.
g.V().has('PRODUCT', 'id', '2').as('a').in('purchased').out('purchased').where(neq('a')).groupCount().order(local).by(values, Order.decr)
returns
==>[4:3,6:2,7:2,12:2,13:2,14:2,15:2,1:1,3:1,5:1,8:1,9:1,10:1,11:1,16:1,17:1]
gremlin gives me an array with all the results, so I cannot use the limit step or range step. How could I select only the first five entries of the array?