Janusgraph常用操作

2021-09-26 13:54:23 字數 3094 閱讀 6462

mgmt = graph.openmanagement()

name = mgmt.getpropertykey("name")

//composite index

mgmt.buildindex(index_name,vertex.class).addkey(name).buildcompositeindex();

//mixed index,需要指定索引後端(與composite index的差別)

mgmt.buildindex(index_name,vertex.class).addkey(name).buildmixedindex(index_backend_name)

mgmt.commit

schemaaction.register_index

schemaaction.reindex

schemaaction.enable_index

schemaaction.disable_index

schemaaction.remove_index

mgmt = graph.openmanagement()

mgmt.updateindex(mgmt.getgraphindex(index_name),schemaaction.reindex).get()

mgmt.commit()

mgmt=graph.openmanagement()

//建立頂點label

mgmt.makevertexlabel(vertex_label_name)[.partition()].make()

//建立邊label,邊關係型別:mutlplicity.mult,mutlplicity.******,mutlplicity.many2one

mgmt.makeedgelabel(edge_label_name).mutiplicity(mutlplicity.mult).make

//新增屬性property

mgmt.commit

mgmt=graph.openmanagement()

mgmt.getgraphindex("typev").getindexstatus(mgmt.getpropertykey("索引屬性"))

mgmt.getgraphindex("typee").getindexstatus(mgmt.getpropertykey("索引屬性"))

mgmt.commit()

mgmt=graph.openmanagement()

mgmt.updateindex(mgmt.getgraphindex("typev"),schemaaction.register_index).get()

mgmt.updateindex(mgmt.getgraphindex("typee"),schemaaction.register_index).get()

mgmt.commit()

graph.openmanagement()

mgmt.makevertexlabel("im").make()

mgmt.commit()

mgmt=graph.openmanagement()

mr = new mapreduceindexmanagement(graph)

--reindex on mr

mr.updateindex(mgmt.getgraphindex("typev"),schemaaction.reindex).get()

mr.updateindex(mgmt.getgraphindex("typee"),schemaaction.reindex).get()

--reindex

mgmt.updateindex(mgmt.getgraphindex("typev"),schemaaction.reindex).get()

mgmt.updateindex(mgmt.getgraphindex("typee"),schemaaction.reindex).get()

mgmt.commit()

//disable

mgmt=graph.openmanagement()

mgmt.updateindex(mgmt.getgraphindex("typev"),schemaaction.disable_index).get()

mgmt.updateindex(mgmt.getgraphindex("typee"),schemaaction.disable_index).get()

mgmt.commit()

managementsystem.awaitgraphindexstatus(graph, 'name').status(schemastatus.disabled).call()

//remove

mgmt=graph.openmanagement()

mgmt.updateindex(mgmt.getgraphindex("typev"),schemaaction.remove_index).get()

mgmt.updateindex(mgmt.getgraphindex("typee"),schemaaction.remove_index).get()

mgmt.commit()

//停止已經開啟的會話(否則無法操作index)

graph.getopentransactions().iterator().next().rollback()

//停止所有圖例項 mgmt.forcecloseinstance( mgmt.getopeninstances().toset()[1])

//等待生效 mgmt.awaitgraphindexstatus(graph,index_name).call()

v2=graph.indexquery("typev", "索引key:value ").vertexstream().findfirst()

v2.get().getelement().properties()

JanusGraph資料備份與恢復

janusgraph官方文件並沒有他提供資料備份與恢復的相關說明,所以我們是使用的tinkerpop的備份與恢復命令。tinkerpop資料備份方式有三種 1 graphml 備份 graph.io iocore.graphml writegraph usr local janusgraph 0.2...

centos7下安裝janusGraph單機版

janusgraph是一款圖資料庫,繼承自titan,支援分布式,可以整合了多種資料庫,大資料平台,如hbase,hadoop,spark,elasticsearch等。詳細介紹大家可參考官方文件janusgraph官方文件。下面我們介紹如何在centos7上安裝配置單機版本的janusgraph....

JanusGraph 2 1 架構預覽

architectural overview janusgraph是乙個圖資料庫引擎.janusgraph集中在圖的序列化,圖的資料模型和高效的查詢.此外janusgraph依賴hadoop來做圖的統計和批量圖操作.janusgraph為資料儲存,索引和客戶端訪問實現了粗粒度的模組介面.janusg...