繁体   English   中英

如何将卡桑德拉中存在的泰坦图索引到Solr

[英]How to index Titan graph present in cassandra to solr

我已经在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中索引同一张图。

  1. 如何使用Java做到这一点?
  2. 我是否要查询键空间和索引表? 在solr中索引相同图形的方法是什么?

Titan与solr直接集成。 这意味着无需直接与solr交谈。 相反,您可以让titan与您交谈,并且在遍历图形时自然会发生这种情况。

您所要做的就是按照此处定义的那样设置索引。 在此处提供了使用Solr / Elastic搜索优化的混合索引的示例。

因此,在上面的示例中,每当您执行特定类型的遍历时,titan和solr都会快速响应。

请记住,您必须创建一个混合索引。

除了定义索引之外,还必须使titan与solr一起运行。 不幸的是,这并不是那么简单。 您必须先运行solr,然后像我在这里所做的那样,让titan与solr交谈

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM