0

即使我没有在任何地方配置它,看起来我也遇到了弹性搜索问题:(

应用程序代码(Java):

public static void main(String args[]) {
    JanusGraph g = JanusGraphFactory.open("/path/to/file/janusgraph-solr.properties");
    GraphOfTheGodsFactory.load(g);
    g.close();
}

配置(janushgraph-solr.properties):

# Change to the directory where JanusGraph was extracted.  Later commands
# use relative paths to the Solr config files shipped with the JanusGraph
# distribution.
cd $JANUSGRAPH_HOME

# The name must be URL safe and should contain one dot/full-stop
# character. The part of the name after the dot must not conflict with
# any of JanusGraph's internal CF names.  Starting the part after the dot
# "solr" will avoid a conflict with JanusGraph's internal CF names.
CORE_NAME=testt
# Where to upload collection configuration and send CoreAdmin requests.
SOLR_HOST=localhost:8983

# The value of index.[X].solr.http-urls in JanusGraph's config file
# should match $SOLR_HOST and $CORE_NAME.  For example, given the
# $CORE_NAME and $SOLR_HOST values above, JanusGraph's config file would
# contain (assuming "search" is the desired index alias):
#
 index.search.solr.http-urls=http://localhost:8983/solr/testt
#
# The stock JanusGraph config file conf/janusgraph-cassandra-solr.properties
# ships with this http-urls value.

storage.backend=cassandrathrift

作为参考,这里是GraphOfTheGods 文件

我收到以下错误:

Exception in thread "main" java.lang.IllegalArgumentException: Could not instantiate implementation: org.janusgraph.diskstorage.es.ElasticSearchIndex
    at org.janusgraph.util.system.ConfigurationUtil.instantiate(ConfigurationUtil.java:69)
    at org.janusgraph.diskstorage.Backend.getImplementationClass(Backend.java:477)
    at org.janusgraph.diskstorage.Backend.getIndexes(Backend.java:464)
    at org.janusgraph.diskstorage.Backend.<init>(Backend.java:149)
    at org.janusgraph.graphdb.configuration.GraphDatabaseConfiguration.getBackend(GraphDatabaseConfiguration.java:1850)
    at org.janusgraph.graphdb.database.StandardJanusGraph.<init>(StandardJanusGraph.java:134)
    at org.janusgraph.core.JanusGraphFactory.open(JanusGraphFactory.java:107)
    at org.janusgraph.core.JanusGraphFactory.open(JanusGraphFactory.java:75)
    at graph.red_graph.App.main(App.java:29)
Caused by: java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
    at org.janusgraph.util.system.ConfigurationUtil.instantiate(ConfigurationUtil.java:58)
    ... 8 more
Caused by: org.elasticsearch.client.transport.NoNodeAvailableException: None of the configured nodes are available: []
    at org.elasticsearch.client.transport.TransportClientNodesService.ensureNodesAreAvailable(TransportClientNodesService.java:279)
    at org.elasticsearch.client.transport.TransportClientNodesService.execute(TransportClientNodesService.java:198)
    at org.elasticsearch.client.transport.support.InternalTransportClusterAdminClient.execute(InternalTransportClusterAdminClient.java:86)
    at org.elasticsearch.client.support.AbstractClusterAdminClient.health(AbstractClusterAdminClient.java:127)
    at org.elasticsearch.action.admin.cluster.health.ClusterHealthRequestBuilder.doExecute(ClusterHealthRequestBuilder.java:92)
    at org.elasticsearch.action.ActionRequestBuilder.execute(ActionRequestBuilder.java:91)
    at org.elasticsearch.action.ActionRequestBuilder.execute(ActionRequestBuilder.java:65)
    at org.janusgraph.diskstorage.es.ElasticSearchIndex.<init>(ElasticSearchIndex.java:215)
    ... 13 more
4

2 回答 2

1

当我从 Janus v0.1.1 迁移到 v0.2.0 时,我可以重现此错误 之前使用 v0.1.1 我使用的是 cassandra+ES。在 v0.2.0 中,我想运行 cassandra+Solr。即使在配置文件中没有提到 ES,我仍然收到 node not available 错误。

我删除了 cassandra 的元数据,删除了 keyspace 和 db 文件夹。并从头开始 solr 和 Cassandra。这似乎解决了我的问题。我相信 cassandra 期望 ES 进行索引,因此需要清除它。

于 2018-01-22T12:10:47.187 回答
1

GraphOfTheGodsFactory 使用弹性搜索作为索引后端

因此,如果您想要一个示例架构,只需使用以下架构

JanusGraph graph = JanusGraphFactory.open("/path/to/file/janusgraph-solr.properties");
String mixedIndexName = "search"; //Your Solr Collection/Core Name
boolean uniqueNameCompositeIndex = true;

JanusGraphManagement mgmt = graph.openManagement();
final PropertyKey name = mgmt.makePropertyKey("name").dataType(String.class).make();
JanusGraphManagement.IndexBuilder nameIndexBuilder = mgmt.buildIndex("name", Vertex.class).addKey(name);
if (uniqueNameCompositeIndex)
    nameIndexBuilder.unique();
JanusGraphIndex namei = nameIndexBuilder.buildCompositeIndex();
mgmt.setConsistency(namei, ConsistencyModifier.LOCK);
final PropertyKey age = mgmt.makePropertyKey("age").dataType(Integer.class).make();
if (null != mixedIndexName)
    mgmt.buildIndex("vertices", Vertex.class).addKey(age).buildMixedIndex(mixedIndexName);

final PropertyKey time = mgmt.makePropertyKey("time").dataType(Integer.class).make();
final PropertyKey reason = mgmt.makePropertyKey("reason").dataType(String.class).make();
final PropertyKey place = mgmt.makePropertyKey("place").dataType(Geoshape.class).make();
if (null != mixedIndexName)
    mgmt.buildIndex("edges", Edge.class).addKey(reason).addKey(place).buildMixedIndex(mixedIndexName);

mgmt.makeEdgeLabel("father").multiplicity(Multiplicity.MANY2ONE).make();
mgmt.makeEdgeLabel("mother").multiplicity(Multiplicity.MANY2ONE).make();
EdgeLabel battled = mgmt.makeEdgeLabel("battled").signature(time).make();
mgmt.buildEdgeIndex(battled, "battlesByTime", Direction.BOTH, Order.decr, time);
mgmt.makeEdgeLabel("lives").signature(reason).make();
mgmt.makeEdgeLabel("pet").make();
mgmt.makeEdgeLabel("brother").make();

mgmt.makeVertexLabel("titan").make();
mgmt.makeVertexLabel("location").make();
mgmt.makeVertexLabel("god").make();
mgmt.makeVertexLabel("demigod").make();
mgmt.makeVertexLabel("human").make();
mgmt.makeVertexLabel("monster").make();

mgmt.commit();

JanusGraphTransaction tx = graph.newTransaction();
// vertices

Vertex saturn = tx.addVertex(T.label, "titan", "name", "saturn", "age", 10000);
Vertex sky = tx.addVertex(T.label, "location", "name", "sky");
Vertex sea = tx.addVertex(T.label, "location", "name", "sea");
Vertex jupiter = tx.addVertex(T.label, "god", "name", "jupiter", "age", 5000);
Vertex neptune = tx.addVertex(T.label, "god", "name", "neptune", "age", 4500);
Vertex hercules = tx.addVertex(T.label, "demigod", "name", "hercules", "age", 30);
Vertex alcmene = tx.addVertex(T.label, "human", "name", "alcmene", "age", 45);
Vertex pluto = tx.addVertex(T.label, "god", "name", "pluto", "age", 4000);
Vertex nemean = tx.addVertex(T.label, "monster", "name", "nemean");
Vertex hydra = tx.addVertex(T.label, "monster", "name", "hydra");
Vertex cerberus = tx.addVertex(T.label, "monster", "name", "cerberus");
Vertex tartarus = tx.addVertex(T.label, "location", "name", "tartarus");

// edges

jupiter.addEdge("father", saturn);
jupiter.addEdge("lives", sky, "reason", "loves fresh breezes");
jupiter.addEdge("brother", neptune);
jupiter.addEdge("brother", pluto);

neptune.addEdge("lives", sea).property("reason", "loves waves");
neptune.addEdge("brother", jupiter);
neptune.addEdge("brother", pluto);

hercules.addEdge("father", jupiter);
hercules.addEdge("mother", alcmene);
hercules.addEdge("battled", nemean, "time", 1, "place", Geoshape.point(38.1f, 23.7f));
hercules.addEdge("battled", hydra, "time", 2, "place", Geoshape.point(37.7f, 23.9f));
hercules.addEdge("battled", cerberus, "time", 12, "place", Geoshape.point(39f, 22f));

pluto.addEdge("brother", jupiter);
pluto.addEdge("brother", neptune);
pluto.addEdge("lives", tartarus, "reason", "no fear of death");
pluto.addEdge("pet", cerberus);

cerberus.addEdge("lives", tartarus);

// commit the transaction to disk
tx.commit();

注意:这里 mixedIndexName = "search" 是您的 Solr 集合/核心名称

示例索引后端配置文件:

index.search.backend=solr
index.search.index-name=search
index.search.solr.mode=http
index.search.solr.http-urls=http://192.168.18.12:8983/solr
于 2017-10-03T04:39:57.243 回答