0
我已經在cassandra中存儲了一個titan圖形。以下是代碼。如何索引cassandra中存在的Titan圖形到solr
public class Example1 {
public static void main(String[] args) {
//Initliase graph
BaseConfiguration baseConfiguration = new BaseConfiguration();
baseConfiguration.setProperty("storage.backend", "cassandra");
baseConfiguration.setProperty("storage.hostname", "192.168.3.82");
baseConfiguration.setProperty("storage.cassandra.keyspace", "mycustomerdata");
TitanGraph graph = TitanFactory.open(baseConfiguration);
//---------------- Adding Data -------------------
//Create some customers
Vertex alice = graph.addVertex("customer");
alice.property("name", "Alice Mc Alice");
alice.property("birthdat", "100000 BC");
Vertex bob = graph.addVertex("customer");
bob.property("name", "Bob Mc Bob");
bob.property("birthdat", "1000 BC");
//Create Some Products
Vertex meat = graph.addVertex("product");
meat.property("name", "Meat");
meat.property("description", "Delicious Meat");
Vertex lettuce = graph.addVertex("product");
lettuce.property("name", "Lettuce");
lettuce.property("description", "Delicious Lettuce which is green");
//Alice Bought some meat:
alice.addEdge("bought", meat);
//Bob Bought some meat and lettuce:
bob.addEdge("bought",lettuce);
//---------------- Querying (aka traversing whcih is what you do in graph dbs) Data -------------------
//Now who has bought meat?
graph.traversal().V().has("name", "meat").in("bought").forEachRemaining(v -> System.out.println(v.value("name")));
//Who are all our customers
/*graph.traversal().V().hasLabel("customer").forEachRemaining(v -> System.out.println(v.value("name")));
//What products do we have
graph.traversal().V().hasLabel("product").forEachRemaining(v -> System.out.println(v.value("name")));*/
graph.close();
}
}
我想索引solr中的同一個圖。
- 如何在使用java中做到這一點?
- 我有查詢密鑰空間和索引的表嗎?在solr中索引相同的圖表有什麼方法?
嘿,我跟着你指出的東西。我複製了$ SOLR_HOME/server/solr/configsets/{config_set}下的titan/conf/solr的內容,包括子目錄。我沒有在Solr中創建任何核心,但是使配置代碼看起來像這樣:BaseConfiguration baseConfiguration = new BaseConfiguration(); baseConfiguration.setProperty(「index.search.backend」,「solr」); baseConfiguration.setProperty(「index.search.solr.mode」,「http」); baseConfiguration.setProperty(「index.search.solr.httpurls」,「http://192.168.2.189:8983/solr」); –
但我得到了:java.lang.ClassNotFoundException:com.thinkaurelius.titan.diskstorage.es.ElasticSearchIndex。我不想使用ES,但只有Cassandra用於存儲,Solr用於索引。你可以分享一個示例代碼嗎? –