Reputation: 21
I have a vertex that has nested properties under a specific property. Example:
{
"id": "X",
"label": "deployment",
"type": "vertex",
"properties": {
"name": [
{
"id": "X",
"value": "myvalue1"
}
],
"labels": [
{
"id": "xxxxx",
"value": "my-labels",
"properties": {
"key": "value"
}
}
]
}
}
My problem is: I would like to search for a sub-property with a specific value. How would I construct the query to find vertices with that value? I can't seem to find any documentation on trying to find that sub-property.
Plenty of documentation on finding and sorting on a property of a vertex, but not this.
The goal of doing this, is that there are many "labels" under my labels and I want to eventually create edges among vertices with matching sub labels.
Upvotes: 2
Views: 2687
Reputation: 10904
This will be a scan over all vertices, so be warned that it's not going to be a high-performance query.
g.V().filter(properties("my-labels").has("key", "value"))
To give you an example over The Crew graph:
//
// Where did TinkerPop crew members move in and after 2005?
//
gremlin> g = TinkerFactory.createTheCrew().traversal()
==>graphtraversalsource[tinkergraph[vertices:6 edges:14], standard]
gremlin> g.V().filter(properties("location").has("startTime", gte(2005))).
project("name","locations").
by("name").
by(properties("location").has("startTime", gte(2005)).value().fold())
==>[name:marko,locations:[santa fe]]
==>[name:stephen,locations:[purcellville]]
==>[name:matthias,locations:[baltimore,oakland,seattle]]
==>[name:daniel,locations:[kaiserslautern,aachen]]
Upvotes: 1