Syed Ammar Mustafa
Syed Ammar Mustafa

Reputation: 413

How to index Titan graph present in cassandra to solr

I have stored a titan graph in cassandra. Below is the code.

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();

}
}

I would like index the same graph in solr .

  1. How to do this in using java ?
  2. Do I have query the tables of the keyspace and index ? what's the approach for having the same graph indexed in solr ?

Upvotes: 0

Views: 108

Answers (1)

Filipe Teixeira
Filipe Teixeira

Reputation: 3565

Titan integrates directly with solr. Which means that you never have to talk to solr directly. Rather, you let titan talk with it for you and this happens naturally whenever traversing the graph.

All you have to do is setup your indexing as defined here. I provide an example of using a Mixed index optimised by Solr/Elastic search here.

So in the above example whenever you execute a specific type of traversals titan together with solr will respond quickly.

Just remember you have to create a Mixed Index.

In addition to defining the indices you also have to get titan running with solr. Unfortunately this is not so simple. You have to get solr running and then get titan talking to solr as I have done here

Upvotes: 1

Related Questions