janusgraph index

janusgraph index

查看index

  1. 首先shell的方式连接到janusgraph
    启动bin/gremlin.sh,进入gremlin控制台
  2. 连接本地的gremlin server,
    gremlin>:remote connect tinkerpop.server conf/remote.yaml
    gremlin>:remote console
  3. 打印索引情况
    gremlin>mgmt = graph.openManagement();mgmt.printSchema();

几种index

graph index : composite index 和 minxed index
前者使用存储图数据的后端存储做索引存储,后者借助第三方的索引存储如elasticsearch

Composite indexes do not require configuration of an external indexing backend and are supported through the primary storage backend.

Composite indexes can also be used to enforce property uniqueness in the graph. If a composite graph index is defined as unique() there can be at most one vertex or edge for any given concatenation of property values associated with the keys of that index.

graph.tx().rollback() //Never create new indexes while a transaction is active 
mgmt = graph.openManagement() name = mgmt.getPropertyKey('name') mgmt.buildIndex('byNameUnique', Vertex.class).addKey(name).unique().buildCompositeIndex() mgmt.commit() //Wait for the index to become available 
ManagementSystem.awaitGraphIndexStatus(graph, 'byNameUnique').call() //Reindex the existing data 
mgmt = graph.openManagement() mgmt.updateIndex(mgmt.getGraphIndex("byNameUnique"),SchemaAction.REINDEX).get() 
mgmt.commit()

建议索引在导入数据前建立

The indexes should be created before data is loaded to avoid the need to re-index the graph, which is an expensive process.
在初始化部署数据库时建立composite索引,由于composite index是基于属性的索引,所以需要建立针对业务的一个属性obj_id,建索引的语句为下

mgmt = graph.openManagement();

objId =mgmt.makePropertyKey('obj_id').dataType(String.class).make();

VertexLabel nodeVertexLabel = mgmt.makeVertexLabel("node").make();

JanusGraphIndex objIdIndex = mgmt.buildIndex('byObjIdComposite', Vertex.class).addKey(objId).indexOnly(nodeVertexLabel).unique().buildCompositeIndex();

mgmt.setConsistency(objIdIndex, ConsistencyModifier.LOCK);

mgmt.commit();

如果数据库已经存在数据就需要reindex,这是耗时的一个过程,不建议这么做。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
### 回答1: JanusGraph是一个开源的分布式图数据库,可用于存储和处理大规模图数据。JanusGraph 0.5.2是该数据库的一个特定版本,支持在Windows操作系统上使用。 使用JanusGraph 0.5.2在Windows上需要以下步骤: 1. 下载JanusGraph 0.5.2的安装包。可以从官方网站或GitHub上获取最新的发布版本。 2. 解压安装包到任意目录。确保你的系统上已经安装了Java环境,并且配置了JAVA_HOME环境变量。 3. 打开命令行窗口,进入JanusGraph的目录。 4. 在命令行窗口中运行bin/gremlin.bat脚本。这将启动JanusGraphGremlin Shell,Gremlin是一种图遍历语言,用于与JanusGraph交互。 5. 在Gremlin Shell中,你可以执行各种图数据库的操作,如创建图、添加顶点和边、遍历图等。使用Gremlin脚本文件(.groovy)将多个操作组合到一个文件中,并在Gremlin Shell中执行该文件。 6. 在Gremlin Shell中,你还可以执行Cypher查询语句来查询图数据库中的数据。JanusGraph支持Cypher作为一种查询语言,并提供了相应的API。 7. 当你完成了对JanusGraph的操作,可以通过在Gremlin Shell中使用`:q`命令来退出。 总之,JanusGraph 0.5.2可以在Windows上使用,并且它提供了Gremlin Shell和Cypher查询语言来与图数据库交互。通过执行相应的命令或脚本,你可以在Windows操作系统上创建、修改和查询大规模的图数据。 ### 回答2: JanusGraph 0.5.2是一个开源的分布式图数据库,它是基于Apache TinkerPop图计算框架构建的,并且提供了许多强大的功能和扩展性。 关于在Windows上安装和配置JanusGraph 0.5.2,以下是简单的步骤: 1. 准备环境:首先,确保你有一个可用的Java安装,JanusGraph 0.5.2需要Java 8或更高版本。 2. 下载JanusGraph 0.5.2:在JanusGraph的官方网站或GitHub页面上下载JanusGraph 0.5.2的压缩包。 3. 解压缩文件:解压缩下载的压缩包到一个合适的目录,例如"JanusGraph"文件夹。 4. 配置JanusGraph:在JanusGraph目录中,找到并编辑"janusgraph-hbase.properties"文件。根据你的需要配置数据库后端(如HBase或Cassandra)和相关参数。 5. 启动JanusGraph:在命令提示符或PowerShell窗口中,导航到JanusGraph目录,并运行以下命令启动JanusGraph服务器: ``` bin\janusgraph.bat ``` 6. 使用JanusGraph:一旦服务器启动,你可以使用Gremlin控制台或TinkerPop兼容的图数据库客户端连接到JanusGraph,并执行各种图数据库操作。 如此,你就成功地在Windows上安装和配置了JanusGraph 0.5.2。根据你的具体需求,你可以进一步探索JanusGraph的功能和性能优化。 ### 回答3: JanusGraph 0.5.2是一个开源的分布式图数据库,它可以在Windows操作系统上运行。JanusGraph具有扩展性和可靠性,支持高性能的图数据查询和处理。 在Windows上安装和配置JanusGraph 0.5.2相对简单,以下是一些基本步骤: 1. 首先,在JanusGraph的官方网站上下载适用于Windows的JanusGraph压缩包。 2. 解压缩JanusGraph压缩包到你选择的目录中。 3. 打开目录中的`conf`文件夹,在这里你可以找到`janusgraph.properties`文件。 4. 使用一个文本编辑器打开`janusgraph.properties`文件,对其进行必要的配置。你需要指定一个Cassandra或HBase的存储后端,以及一些其他的配置选项。此外,你还可以根据需求进行其他配置调整,例如调整缓存和连接池的大小等。 5. 保存并关闭`janusgraph.properties`文件。 6. 打开命令提示符,并进入JanusGraph目录下的`bin`文件夹。 7. 在命令提示符中,输入以下命令以启动JanusGraph服务器: ``` janusgraph.bat start ``` 8. 等待一段时间,直到看到类似于“Graph database loaded (...)”的消息。 9. 现在,JanusGraph服务器已经在Windows上成功启动。 10. 如果需要连接到JanusGraph服务器并执行图数据库操作,可以使用Gremlin控制台或通过客户端编程语言(如Java、Python等)与JanusGraph进行通信。 总的来说,JanusGraph 0.5.2可以在Windows上运行,只需进行一些简单的配置即可。希望这些步骤对你有帮助。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值