Reputation: 41
Here is the configuration options i am using.
storage.backend=cassandra
storage.hostname=192.168.56.121
storage.cassandra.keyspace=graphs
cache.db-cache = false
cache.db-cache-clean-wait = 20
index.search.backend=elasticsearch
index.search.hostname=192.168.56.122
index.search.elasticsearch.client-only=true
index.search.index-name=graphs
TitanGraph graph = GraphFactory.getInstance().getGraph();
TitanManagement mgmt = null;
try {
mgmt = graph.openManagement();
PropertyKey name = mgmt.getPropertyKey(Schema.NAME);
if (name == null) {
name = mgmt.makePropertyKey(Schema.NAME).dataType(String.class).make();
}
TitanGraphIndex graphIndex = mgmt.getGraphIndex("byName");
if (graphIndex == null) {
IndexBuilder builder = mgmt.buildIndex("byName", Vertex.class).addKey(name);
builder.buildCompositeIndex();
}
PropertyKey id = mgmt.getPropertyKey(Schema.ID);
if (id == null) {
id = mgmt.makePropertyKey(Schema.ID).dataType(Long.class).make();
}
PropertyKey sourceType = mgmt.getPropertyKey(Schema.SOURCE_TYPE);
if (sourceType == null) {
sourceType = mgmt.makePropertyKey(Schema.SOURCE_TYPE).dataType(String.class).make();
}
TitanGraphIndex uniqueIndex = mgmt.getGraphIndex("uniqueIndex");
if (uniqueIndex == null) {
IndexBuilder builder = mgmt.buildIndex("uniqueIndex", Vertex.class).addKey(id).addKey(sourceType);
builder.unique().buildCompositeIndex();
}
// Edges
EdgeLabel deps = mgmt.getEdgeLabel("deps");
if (deps == null) {
deps = mgmt.makeEdgeLabel("deps").multiplicity(Multiplicity.SIMPLE).make();
}
RelationTypeIndex depsIndex = mgmt.getRelationIndex(deps, "depsIndex");
if(depsIndex == null) {
depsIndex = mgmt.buildEdgeIndex(deps, "depsIndex", Direction.BOTH, Order.decr);
}
mgmt.commit();
// Re index the existing data
if (reIndexData) {
mgmt = graph.openManagement();
mgmt.updateIndex(mgmt.getGraphIndex("uniqueIndex"), SchemaAction.REINDEX).get();
mgmt.updateIndex(mgmt.getGraphIndex("byName"), SchemaAction.REINDEX).get();
deps = mgmt.getEdgeLabel("deps");
mgmt.updateIndex(mgmt.getRelationIndex(deps,"depsIndex"), SchemaAction.REINDEX).get();
mgmt.commit();
}
} catch (Throwable e) {
log.error(e.getMessage(), e);
if (mgmt != null) {
mgmt.rollback();
}
}
I have created lots of documents and every thing is working fine. But when i observed the number document available in the elastic search is 0.
I am wondered whether titan db really using the elastic search or not.
Any idea what i am missing here ? And why documents are not getting created in elastic search.
And i also tried the belown configuration as well but no luck
storage.backend=cassandra
storage.hostname=192.168.56.121
storage.cassandra.keyspace=graphs
cache.db-cache = false
cache.db-cache-clean-wait = 20
index.graphs.backend=elasticsearch
index.graphs.hostname=192.168.56.122
index.graphs.elasticsearch.client-only=true
index.graphs.index-name=graphs
Upvotes: 0
Views: 63
Reputation: 12830
Titan uses storage backend (cassandra/hbase) for Composite Index and index backend (Solr/Elastic Search) for Mixed Index
Mixed indexes retrieve vertices or edges by any combination of previously added property keys. Mixed indexes provide more flexibility than composite indexes and support additional condition predicates beyond equality. On the other hand, mixed indexes are slower for most equality queries than composite indexes.
Unlike composite indexes, mixed indexes require the configuration of an indexing backend and use that indexing backend to execute lookup operations. Titan can support multiple indexing backends in a single installation. Each indexing backend must be uniquely identified by name in the Titan configuration which is called the indexing backend name.
In you schema you are creating only composite index. That's why there is not data in ElasticSearch.
Here is a example how to create a mixed index :
IndexBuilder builder = mgmt.buildIndex('byName', Vertex.class).addKey(name);
builder.buildMixedIndex("search");
mgmt.commit();
Source : http://s3.thinkaurelius.com/docs/titan/1.0.0/indexes.html
Upvotes: 2