From 924edac92048d48d1507a55ebe50a1314ce584d9 Mon Sep 17 00:00:00 2001 From: Stephen Mallette Date: Fri, 10 Nov 2023 09:58:07 -0500 Subject: [PATCH] Added element() step content #271 --- book/Section-Beyond-Basic-Queries.adoc | 29 ++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/book/Section-Beyond-Basic-Queries.adoc b/book/Section-Beyond-Basic-Queries.adoc index a9d3003..3b7dd25 100644 --- a/book/Section-Beyond-Basic-Queries.adoc +++ b/book/Section-Beyond-Basic-Queries.adoc @@ -1334,8 +1334,8 @@ desc ---- We could likewise find the names, with duplicates removed, of any property keys -associated with any outgoing edges from the DFW vertex using this query. Note that edge -properties are implementations of 'Property' and not 'VertexProperty'. +associated with any outgoing edges from the DFW vertex using this query. Note that +edge properties are implementations of 'Property' and not 'VertexProperty'. [source,groovy] ---- @@ -1358,6 +1358,31 @@ g.V().hasLabel("airport"). [longest:25497644, runways:4816] ---- +[[elementstep]] +The 'element' traversal step +^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +When you use the 'properties' step to navigate to a property object, you may find +that you want to return to the parent element that it is related to. The 'element' +step is used for this purpose and can be used to navigate from a property back to a +vertex, edge or vertex property. That final case of a "vertex property" refers to +situations where you have used 'properties' to access a meta-property as described +a bit later in the <> section. + +[source,groovy] +---- +g.V().has('airport','code','IAD'). + properties('code','city').element() + +v[10] +v[10] +---- + +In the example shown above, we can see that "v[10]" is returned twice because +'element' was called twice, once for the "code" property and once for the "city" +property and both belong to the "v[10]" vertex. + [[propmap]] The 'propertyMap' traversal step ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^