Find nodes by pattern matching #
Problem #
How can I find nodes by pattern matching?
For example, how can I find all movies with title that has the ".*Lord of.*"
pattern?
Solution #
Gizmo Query with regex()
#
g.V().Has("<type>","</film/film>").Out("<name>").Filter(like("%Lord of %")).All()
Results:
{"id":"Greystoke - The Legend of Tarzan, Lord of the Apes"}
{"id":"Lord of Illusions"}
{"id":"Lord of the Beans"}
{"id":"Lord of the Flies"}
{"id":"Lord of War"}
{"id":"Phantasm III: Lord of the Dead"}
{"id":"The Lord of the Rings"}
{"id":"The Lord of the Rings: The Fellowship of the Ring"}
{"id":"The Lord of the Rings: The Return of the King"}
{"id":"The Lord of the Rings: The Two Towers"}
Gizmo Query with like()
#
g.V().Has("<type>","</film/film>").Out("<name>").Filter(like("%Lord of the Rings%")).All()
Results:
{"id":"The Lord of the Rings"}
{"id":"The Lord of the Rings: The Fellowship of the Ring"}
{"id":"The Lord of the Rings: The Return of the King"}
{"id":"The Lord of the Rings: The Two Towers"}