我正在尝试使用janusgraph创建一个模式,并使用cassandra作为后端存储,使用elasticsearch作为索引器。使用以下代码连接到janusgraph:
Graph graph = GraphFactory.open(CONFIG_FILE);
配置文件的内容是:
gremlin.graph=org.janusgraph.core.JanusGraphFactory
storage.backend=cassandrathrift
storage.hostname=127.0.0.1
storage.cassandra.keyspace=JanusGraph
cache.db-cache = true
cache.db-cache-clean-wait = 20
cache.db-cache-time = 180000
cache.db-cache-size = 0.25
index.search.backend=elasticsearch
index.search.hostname=127.0.0.1
index.search.port=9300
我创建索引的方法如下:
VertexLabel user = mgt.makeVertexLabel(USER).make();
PropertyKey userName =
mgt.makePropertyKey(USER_NAME).dataType(String.class).make();
//building mixed index (i.e. we use external indexer)
mgt.buildIndex(indexName(USER, USER_NAME), Vertex.class).
addKey(userName, Mapping.STRING.asParameter()).
indexOnly(user).
buildMixedIndex(BACKING_INDEX);
如您所见,我首先创建顶点,然后索引一些属性。
当我在不使用indexer的情况下运行代码时,我没有遇到任何问题,但是当我使用indexer时,出现以下异常:
Exception in thread "main" java.lang.IllegalArgumentException: Could not find implementation class: org.janusgraph.diskstorage.es.ElasticSearchIndex
at org.janusgraph.util.system.ConfigurationUtil.instantiate(ConfigurationUtil.java:60)
at org.janusgraph.diskstorage.Backend.getImplementationClass(Backend.java:476)
at org.janusgraph.diskstorage.Backend.getIndexes(Backend.java:463)
at org.janusgraph.diskstorage.Backend.<init>(Backend.java:148)
at org.janusgraph.graphdb.configuration.GraphDatabaseConfiguration.getBackend(GraphDatabaseConfiguration.java:1840)
at org.janusgraph.graphdb.database.StandardJanusGraph.<init>(StandardJanusGraph.java:138)
at org.janusgraph.core.JanusGraphFactory.open(JanusGraphFactory.java:160)
at org.janusgraph.core.JanusGraphFactory.open(JanusGraphFactory.java:131)
at org.janusgraph.core.JanusGraphFactory.open(JanusGraphFactory.java:78)
at mounaf.janusgraph.Schema.<init>(Schema.java:61)
at mounaf.janusgraph.BuiltinQueries.main(BuiltinQueries.java:16)
Caused by: java.lang.ClassNotFoundException: org.janusgraph.diskstorage.es.ElasticSearchIndex
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:264)
at org.janusgraph.util.system.ConfigurationUtil.instantiate(ConfigurationUtil.java:56)
... 10 more
你能帮我解决这个问题吗。
2条答案
按热度按时间smdncfj31#
你得到了classnotfoundexception
java.lang.ClassNotFoundException: org.janusgraph.diskstorage.es.ElasticSearchIndex
我想您还没有在您的应用程序中添加janusgraph elasticsearch依赖项pom.xml
文件。将下面的依赖项添加到pom.xml
文件来修复此问题zte4gxcn2#
我记得在java中使用openmanagement方法时遇到了问题,但我使用client.submit(string gremlin)来配置我的模式和索引,结果成功了。