Tinkerpop (1) graph Database console survey, tinkerpopconsole
The original Article connection: http://blog.csdn.net/freewebsys/article/details/46348975 reproduced please indicate the source!
1. About graph database
Tinkerpop is a project under the apache incubator.
Open-source graph database engines use neo4j, which is the most widely used graph database engine. However, there are copyright restrictions. If you use a Community version, you can only run it on a single machine.
Http://tinkerpop.incubator.apache.org/
Reference:
Http://tinkerpop.incubator.apache.org/docs/3.0.0.M9-incubating/
2. Start the console.
wget https://dist.apache.org/repos/dist/release/incubator/tinkerpop/3.0.0.M9-incubating/apache-gremlin-console-3.0.0.M9-incubating-bin.zipunzip apache-gremlin-console-3.0.0.M9-incubating-bin.zipmv apache-gremlin-console-3.0.0.M9-incubating console
Start console: (you can start it separately) You can try the command to test data, but the data is stored in the memory. If it is disabled, it will be lost.
Cd console # sh bin/gremlin. sh \,/(o) ----- oOOo-(3)-oOOo ----- plugin activated: tinkerpop. serverplugin activated: tinkerpop. utilitiesplugin activated: tinkerpop. sugarplugin activated: tinkerpop. tinkergraph # Open the connection gremlin> g = TinkerGraph. open () ==> tinkergraph [vertices: 0 edges: 0] # create a three-member data gremlin> zhangsan = g. addVertex ("name", "zhangsan") => v [0] # create Li Si data gremlin> lisi = g. addVertex ("name", "lisi") ==> v [2] # create a king Five data gremlin> wangwu = g. addVertex ("name", "wangwu") => v [4] # sets the friend relationship between Li Si and Wang Wu. friend is the name of the connection and can be obtained at will. Gremlin> lisi. addEdge ("friend", zhangsan) => e [6] [2-friend-> 0] # Set the relationship between Wang Wu and Li Si, gremlin> wangwu. addEdge ("friend", lisi) ==> e [7] [4-friend-> 2] # query all data gremlin> g. vertices () ==> v [0] ==> v [2] ==> v [4] # query the relationship gremlin> g. edges () ==> e [6] [2-friend-> 0] ==> e [7] [4-friend-> 2] gremlin> zhangsan ==> v [0] # Delete Zhang San data gremlin> zhangsan. remove () ==> null # All data after deletion gremlin> g. vertices () ==> v [2] ==> v [4] # The deleted relational data gremlin> g. edges () => e [7] [4-friend-> 2]
Enable the OLTP Variable Engine
# Enable the Variable Engine gtgremlin> gt = g. traversal (standard () ==> graphtraversalsource [tinkergraph [vertices: 2 edges: 1], standard] gremlin ># View data gremlin> gt. V () ==> v [2] ==> v [4] # query the user gremlin whose name is lisi> gt. V (). has ("name", "lisi") => v [2] # query friends of Li Si, because Zhang San was deleted just now. All without data. Gremlin> gt. V (). has ("name", "lisi "). out ("friend "). values ("name") # query Wang's friends. The relationship is unidirectional. Gremlin> gt. V (). has ("name", "wangwu"). out ("friend"). values ("name") => lisi
Official examples:
# Initialize data gremlin> g = TinkerFactory. createModern () ==> tinkergraph [vertices: 6 edges: 6] # initialize the traversal engine gremlin> gt = g. traversal (standard () ==> graphtraversalsource [tinkergraph [vertices: 6 edges: 6], standard] # query marko knows by gremlin> gt. V (). has ('name', 'marko '). out ('done '). values ('name') ==> vadas ==> josh # query marko created by gremlin> gt. V (). has ('name', 'marko '). out ('created '). values ('name') => lop # query the marko knows and the created persons gremlin> gt. V (). has ('name', 'marko '). out ('done '). out ('created '). values ('name') ==> ripple ==> lop # query the gremlin by josh created> gt. V (). has ('name', 'Josh '). out ('created '). values ('name') ==> ripple ==> lop
Graph databases provide intuitive inserts and queries.
More query reference Official Website: http://tinkerpop.incubator.apache.org/docs/3.0.0.M9-incubating/
3. Summary
The original Article connection: http://blog.csdn.net/freewebsys/article/details/46348975 reproduced please indicate the source!
Graph database is very convenient. The console is a standalone memory version that can be tested and queried.
The production environment deployment requires the server version. Continue the study.