在上一篇JanusGraph建立新图的文章中,一位热心同窗提出一个很棒的问题,就是问我索引配置里官网N次提到的[X]究竟是什么?本身动手实践了一番,整理成此文,以期探讨。shell
+++++++++++(贴原评):后端
略微一搜:JanusGraph的官网配置文档里[X]出现了上百次=>ES配置传送门bash
Note:JanusGraph’s index options start with the string "index.[X]." where "[X]" is a user-defined name for the backend. This user-defined name must be passed to JanusGraph’s ManagementSystem interface when building a mixed index, as described in Mixed Index, so that JanusGraph knows which of potentially multiple configured index backends to use. Configuration snippets in this chapter use the name search, whereas prose discussion of options typically write [X] in the same position. The exact index name is not significant as long as it is used consistently in JanusGraph’s configuration and when administering indices.elasticsearch
如【全程实战】怎么新建JanusGraph图并写入数据?所述的,关键的三个[X]是:post
#索引后端
index.search.backend=elasticsearch
# ES服务的节点地址及端口,:9200能够不写
index.search.hostname=mhostname1:9200,hostname2:9200,hostname3:9200
# 在ES中的索引别名
index.sanguo.index-name=sanguosha
复制代码
执行mgmt.buildIndex('age', Vertex.class).addKey(age).buildMixedIndex("sanguo")
这个实测结果在ES里生成的索引别名是sanguosha
。学习
在评论里说明的是index.[X].backend
的默认值是elasticsearch
,因此结果看似是彻底正确的。实际上,若此时配置index.search.backend=solr则索引不会建立在solr里。由于只调用了index.sanguo.index-name=sanguosha
这一配置,没有对应的backend和hostname配置项。ui
规范的写法应该是:this
#索引后端
index.sanguo.backend=elasticsearch
# ES服务的节点地址及端口,:9200能够不写
index.sanguo.hostname=mhostname1:9200,hostname2:9200,hostname3:9200
# 在ES中的索引别名
index.sanguo.index-name=sanguosha
复制代码
如此,执行buildMixedIndex("sanguo")
才万无一失。这就是说配置文件里能够写多套索引后端的配置,在使用时能够酌情翻牌子。spa
经实测发现:翻译
有帮助的话,请点赞鼓励一下~
JanusGraph实战笔记系列: