@@ -4960,6 +4960,25 @@ g.V().has('airport','city','London').
4960
4960
[country:[CA],code:[YXU],region:[CA-ON]]
4961
4961
----
4962
4962
4963
+ As the 'where' step takes a predicate for its matching conditions, it allows for a
4964
+ great deal of flexibilty in the types of filtering that you can do. In the following
4965
+ example, we find '"IAD"' and use the first three letters of its city name to find
4966
+ other airports that start with those three letters:
4967
+
4968
+ [source,groovy]
4969
+ ----
4970
+ g.V().has('airport','code','IAD').as('a').
4971
+ V().hasLabel('airport').
4972
+ where(startingWith('a')).
4973
+ by('city').
4974
+ by(values('city').substring(0,3)).
4975
+ values('city')
4976
+ ----
4977
+
4978
+ Note that the order of the 'by' modulators is such that the first 'by' refers to the
4979
+ incoming traverser to 'where' and the second refers to the "a" vertex referenced in
4980
+ the 'startingWith' .
4981
+
4963
4982
We've seen how the number of 'by' modulators correspond to the parameters in the
4964
4983
'where' and that they are applied in a round-robin fashion, starting with the
4965
4984
value of the traverser being compared and then to the values it is to be compared
@@ -5028,11 +5047,6 @@ Nice. Note that this also means that Nice is included in the results. Lastly we
5028
5047
the part of the query that prepares the output in a form we want in a 'local' step so
5029
5048
that a separate list is created for each airport.
5030
5049
5031
- You could write this query other ways, perhaps using a 'match' step but once you
5032
- understand the pattern used above it is both fairly simple and quite powerful.
5033
-
5034
-
5035
-
5036
5050
[[choose]]
5037
5051
Using 'choose' to write if... then... else type queries
5038
5052
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
0 commit comments