@@ -4960,6 +4960,39 @@ g.V().has('airport','city','London').
4960
4960
[country:[CA],code:[YXU],region:[CA-ON]]
4961
4961
----
4962
4962
4963
+ We've seen how the number of 'by' modulators correspond to the parameters in the
4964
+ 'where' and that they are applied in a round-robin fashion, starting with the
4965
+ value of the traverser being compared and then to the values it is to be compared
4966
+ with. We can further see this on display when we look at a query that uses 'between'
4967
+ where there are three arguments to consider. For example, let's imagine we wanted to
4968
+ find five airports that have a number of runways that are between one less and one
4969
+ more than 'IAD' .
4970
+
4971
+ [source,groovy]
4972
+ ----
4973
+ g.V().has('airport','code','IAD').values('runways').as('iadl','iadh').
4974
+ V().hasLabel('airport').
4975
+ where(between('iadl','iadh')).
4976
+ by('runways').
4977
+ by(math('_ - 1')).
4978
+ by(math('_ + 1')).
4979
+ limit(5).
4980
+ values('code').fold()
4981
+
4982
+ [ANC,BNA,BWI,DCA,KNS]
4983
+ ----
4984
+
4985
+ In this prior example, we find IAD and then keep that value in two step labels. Those
4986
+ labels are used later as arguments to 'between' . Note that there are three 'by'
4987
+ modulators that follow the 'where' . The first refers to the current airport vertex
4988
+ that we are considering for this filter and that 'by' ensures we use the runways
4989
+ value in the comparison to 'between' . You can see that this initial 'by' relates to
4990
+ an implied reference to the current traverser as there is no label for it present in
4991
+ the 'where' . The second two 'by' modulators refers to the step labels in the
4992
+ 'between' and do a 'math' operation that subtract and add 1 to the number of runways
4993
+ for 'IAD' . In this way, you get the effect of dynamically calculating filtering
4994
+ arguments based on a prior portion of a query.
4995
+
4963
4996
Let's imagine that we want to write a query to find all airports that have the same
4964
4997
region code as the French airport of Nice. Let's assume for now that we do not know
4965
4998
what the region code is so we cannot just write a simple query to find all airports
0 commit comments