JanusGraph基於Gremlin使用總結


1,查詢label為'document'的點

 g.V().hasLabel('document')

2,查詢對應屬性的點是否存在

g.V().hasLabel("document").has("doc_id","2019-09-23 17:45:26.0_00845569-a566-4270-afa7-aacc00140451")

3,刪除點

g.V('600').drop() //id

4,從頂點開始單步遍歷到某層(不返回單步步數超過途徑的點和邊)

g.V().hasLabel("document").has("doc_id","0007e43b-b3ac-4e6c-9f87-a85100a712cd_2019-10-08 09:46:04.0")
.inE()
.outV()
.inE()
.outV()
.path()

5,查看單個圖的整體結構

g.V().outE().as("e").inV().has("doc_id","0007e43b-b3ac-4e6c-9f87-a85100a712cd_2019-10-08 09:46:04.0").select("e")

 6,增加點和邊,指定屬性和label

//非葉子節點 
Vertex thisVertex = g.addV(key).property("doc_id", doc_id).next();
 g.addE(key).from(thisVertex).to(lastVertex).next();
//葉子節點
vertex = g.addV(key).property("text", text).next();
g.addE(key).from(vertex).to(lastVertex).property("index", index).next();

 7,清除數據庫

g.V().drop().iterate()

參考:https://stackoom.com/question/rlaL/Gremlin%E5%88%A0%E9%99%A4%E6%89%80%E6%9C%89%E9%A1%B6%E7%82%B9

8,查詢全表,建索引后不會有warn

g.V().has("doc_id", "ccc_0").inE()

9,啟動JN

nohup sh bin/gremlin-server.sh conf/gremlin-server/gremlin-server.yaml &

10,根據點id查詢相鄰的邊id

g.V(12520).outE().id()

11,根據點id查詢相鄰邊的屬性

g.V(12520).outE().values()

可以參考連接:https://jiang-anwei.github.io/2019/07/15/JanusGraph%E5%AD%A6%E4%B9%A0%E7%AC%94%E8%AE%B0/

 12,查詢頂點個數,是否有無重復節點

g.V().hasLabel("document").has("doc_id", "38020ae26ab87f088d927c8ae604bd01").count()

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM