簡體   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