Using JanusGraph with Solr

2019-05-19 07:46发布

问题:

Setting up JanusGraph i noticed the following in the console:

09:04:12,175  INFO ReflectiveConfigOptionLoader:173 - Loaded and initialized config classes: 10 OK out of 12 attempts in PT0.023S
09:04:12,230  INFO Reflections:224 - Reflections took 28 ms to scan 1 urls, producing 2 keys and 2 values 
09:04:12,291  WARN GraphDatabaseConfiguration:1445 - Local setting index.search.index-name=entity (Type: GLOBAL_OFFLINE) is overridden by globally managed value (janusgraph).  Use the ManagementSystem interface instead of the local configuration to control this setting.
09:04:12,294  WARN GraphDatabaseConfiguration:1445 - Local setting index.search.backend=solr (Type: GLOBAL_OFFLINE) is overridden by globally managed value (elasticsearch).  Use the ManagementSystem interface instead of the local configuration to control this setting.
09:04:12,300  INFO CassandraThriftStoreManager:628 - Closed Thrift connection pooler.

and then i see the following:

Exception in thread "main" java.lang.IllegalArgumentException: Could not instantiate implementation: org.janusgraph.diskstorage.es.ElasticSearchIndex

How do i stop using elasticsearch and switch to Solr?

My properties file is as follows:

index.search.backend=solr
index.search.directory=/path/to/directory/for/solr/index/something
index.search.index-name=something
index.search.solr.mode=http
index.search.solr.http-urls=http://127.0.0.1:8983/solr
storage.backend=cassandrathrift

storage.hostname=127.0.0.1
cache.db-cache = true

cache.db-cache-clean-wait = 20

cache.db-cache-time = 180000

cache.db-cache-size = 0.25

回答1:

The answer to this basically the same as this one for Titan. JanusGraph was forked from Titan.

You are probably trying to connect to an existing graph that was previously configured to use Elasticsearch. By default, the keyspace is named janusgraph.

1) You could connect to a different keyspace by updating conf/janusgraph-cassandra.properties

gremlin.graph=org.janusgraph.core.JanusGraphFactory
storage.backend=cassandrathrift
storage.hostname=127.0.0.1
storage.cassandra.keyspace=mygraph

2) You could drop the existing keyspace. If you used bin/janusgraph.sh start from the quick start directions (which starts a single node Cassandra and a single node Elasticsearch),

bin/janusgraph.sh clean

Or if you have a standalone Cassandra installation:

$CASSANDRA_HOME/bin/cqlsh -e 'drop keyspace if exists janusgraph'

Then you would be able to connect with the default conf/janusgraph-cassandra.properties.