I am starting to learn graph databases and have hit a small snag with a query in the Gremlin query language for a proof of concept.
Say I have a vertex that represents a specific type of bolt and each of the properties represent a material and cost that the bolt is available in.
id: bolt-123,
label: part,
properties: [
{ steel : 0.05 },
{ aluminum : 0.02 },
{ iron : 0.03 },
{ plastic : 0.01 }
]
I would like to be able to get a list of all bolts and their cost that are made out of plastic. With my currently limited knowledge of Gremlin, I have been able to come up with the following query:
g.V().hasLabel('part').has('plastic').project('key', 'value').by('id').by('plastic')
which results in
[ { "key": "bolt-123", "value": 0.01 },
{ "key": "bolt-456", "value": 0.02 } ]
While this query makes perfect sense to me, I am hoping to flatten this out a little bit more so that I could have:
[ { "bolt-123", 0.01 },
{ "bolt-456", 0.02 } ]
Thanks for helping a Gremlin newbie out.