Graphics Reference
In-Depth Information
example, the same query for data on product 44 would look like this in
Gremlin:
g.v(44).out('categorization');
Because SPARQL looks more like SQL and Gremlin is closer to a
programming-style grammar, you may find one more natural than the
other, depending on your previous experience. Personally, the authors find
Gremlin a little more intuitive for interactive querying, especially if link
traversal is involved. Gremlin is used for the examples in this chapter.
Gremlin for Graph Queries
The best way to learn Gremlin is to try it out. Launch a Gremlin shell from
the bin directory of your Titan folder again, and issue a command to
reopen the database, assigning the result to a variable that you will use to
reference the graph.
> bin/gremlin.sh
\,,,/
(o o)
-----oOOo-(_)-oOOo-----
gremlin> g = TitanFactory.open('../productdb/
productdb.properties')
Next, try a query. If you are reading this topic, you (hopefully) have an
interest in graphs, so look for any topics in the product catalog that contain
the word “graph” in their titles. Type the following command, where g is the
reference to the graph stored in the last statement, and V is shorthand for
vertices:
gremlin> g.V.has('title',CONTAINS,'Graph')
==>v[871604]
==>v[1449164]
==>v[1894568]
==>v[1974620]
==>v[2621360]
...
Search WWH ::




Custom Search