在上一篇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實戰筆記系列: