作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我在 cassandra 中存储了一张泰坦图。下面是代码。
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 中索引相同的图。
最佳答案
Titan 直接与 solr 集成。这意味着您永远不必直接与 solr 对话。相反,你让泰坦为你与它交谈,每当遍历图表时,这种情况就会自然发生。
您所要做的就是按照定义 here 设置索引。我提供了一个使用 Solr/Elastic 搜索优化的混合索引的示例 here 。
因此,在上面的示例中,每当您与 solr 一起执行特定类型的遍历时,titan 都会快速响应。
请记住您必须创建混合索引。
除了定义索引之外,您还必须让 titan 与 solr 一起运行。不幸的是这并不是那么简单。你必须让 solr 运行,然后让 titan 与 solr 对话,就像我所做的那样 here
关于java - 如何将 cassandra 中存在的 Titan 图索引到 solr,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43934890/
我是一名优秀的程序员,十分优秀!