2017-10-03 4 views
0

Il semble que je frappe un problème avec ElasticSearch même si je ne l'ai pas configuré partout :(ElasticSearch Erreur JanusGraph

application.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 

de fichiers GraphOfTheGods: https://github.com/JanusGraph/janusgraph/blob/master/janusgraph-core/src/main/java/org/janusgraph/example/GraphOfTheGodsFactory.java

Je reçois l'erreur suivante:

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 
+0

Vous utilisez 'GraphOfTheGodsFactory', qui utilise la recherche élastique comme backend d'index –

+0

Si vous voulez un schéma par défaut, copiez simplement le schéma depuis cette ligne https://github.com/JanusGraph/janusgraph/blob/master/janusgraph- core/src/principal/java/org/janusgraph/exemple/GraphOfTheGodsFactory.java # L79 –

+1

Et aussi supprimer la ligne 'GraphOfTheGodsFactory.load (g);' de votre code –

Répondre

0

GraphOfTheGodsFactory utilise la recherche élastique comme back-end index

Donc, si vous voulez un exemple de schéma il suffit d'utiliser le schéma ci-dessous

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(); 

Note: Ici mixedIndexName = "recherche" est votre Solr Collection/Nom de base

Index Exemple Backend fichier de configuration:

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 
+0

hm .. on dirait que cela utilise encore eleasticsearch? je reçois toujours l'exception suivante: 00:46: 11,187 INFO ElasticSearchIndex: 368 - Hôte distant configuré: 127.0.0.1: 9300 Exception dans le fil "principal" java.lang.IllegalArgumentException: Impossible d'instancier l'implémentation: org.janusgraph.diskstorage. es.ElasticSearchIndex – BigBug

+0

Donc dans l'exemple de configuration je dois encore spécifier le storage.backend = cassandrathrift ...? Sans cela, je reçois une erreur que le backend doit être spécifié – BigBug

+0

Si j'ajoute le storage.backend = cassandrathrift je reçois la même exception à propos de elasticsearch – BigBug

0

Je pouvais reproduire cette erreur lors de la migration de Janus v0.1.1 à v0.2.0. Plus tôt avec v0.1.1, j'utilisais cassandra + ES. Avec v0.2.0 je voulais courir Cassandra + Solr. Même si dans le fichier de configuration, il n'y avait aucune mention de ES, je recevais toujours l'erreur noeud non disponible. J'ai supprimé les méta-données de cassandra, j'ai supprimé l'espace-clé et le dossier db. Et a commencé solr et Cassandra à partir de zéro. Cela a semblé résoudre mon problème. Je crois que Cassandra s'attendait à ce que ES soit indexé, d'où la nécessité de l'éclaircir.