0
addV('src').
property(id,'sales__src').
property("index1","brand").
property("index2","time").
property("index3","city1").
property("index4","city2").
property("index5","city3").   
property("index6","city4").
property("index7","city5").
property("index8","city6").
property("index9","city7").
property("index10","city8").
property("index11","city9").
property("index12","city10").
as("sales_src").

When I plot in a graph

    %%gremlin -p v,inE,outV,inE,outV
g.V('city_brand').inE().outV().inE().outV().path().
by(valueMap().with(WithOptions.tokens))

The order of the properties index became

index1

index11

index12

How to force the order to be in 1,2,3,4 order?

48bits
  • 15
  • 3
  • I tested with the given vertex and another vertex with and edge between them. Tried ordering the properties, didn't work. Looks like the order of properties isn't guaranteed by gremlin, https://stackoverflow.com/questions/60162433/aws-neptune-gremlin-property-order You may have to reorder it outside of gremlin in the language of your preference. – learner Nov 25 '21 at 04:39

1 Answers1

0

TinkerPop does not enforce order on graph providers. Insertion order may or may not be preserved by the graph you are using. Neptune is a graph that does not. You can order add order to the Map but it's a string order so you don't quite get what you want:

gremlin> g.V().valueMap().order(local).by(keys).unfold()
==>index1=[brand]
==>index10=[city8]
==>index11=[city9]
==>index12=[city10]
==>index2=[time]
==>index3=[city1]
==>index4=[city2]
==>index5=[city3]
==>index6=[city4]
==>index7=[city5]
==>index8=[city6]
==>index9=[city7]

There is no graph that I'm aware of that will preserve that order. If you needed this sort of ordering in your traversal, I'd suggest that you use the approach I've demonstrated but to prefer letters over numbers for your property key names as in "indexA", "indexB", "indexC", etc. or to pad with zeros as in "index01","index02","index11", etc.

stephen mallette
  • 45,298
  • 5
  • 67
  • 135