inolen/gremlin-node

Creating indices

Closed this issue · 1 comments

mjp0 commented

How do I create indices with this? I'm trying to port directly from Gremlin console.

I'm trying with below:

graphDB.makeTypeSync().nameSync("foo").dataTypeSync('String.class').indexed('Vertex.class').unique('Direction.BOTH').makePropertyKey();

But can't get pass dataTypeSync - I get Error: Could not find method "dataType(java.lang.String)" on class "class com.thinkaurelius.titan.graphdb.types.StandardTypeMaker".

Hi zero-

I've fixed this in version 0.1.13a. See titanExample.js in examples directory. I've also updated the documentation to include a Titan Index example.

var g = require("gremlin"),
    T = g.Tokens,
    Direction = g.Direction,
    Type = g.ClassTypes;

//Titan specific Enums
var UniqCon = g.java.import("com.thinkaurelius.titan.core.TypeMaker$UniquenessConsistency");
var BaseConfiguration = g.java.import('org.apache.commons.configuration.BaseConfiguration');

conf = new BaseConfiguration();
conf.setPropertySync("storage.backend","cassandra");
conf.setPropertySync("storage.hostname","127.0.0.1");
conf.setPropertySync("storage.keyspace","titan");

var TitanFactory = g.java.import('com.thinkaurelius.titan.core.TitanFactory');
var gt = TitanFactory.openSync(conf);
g.SetGraph(gt);

gt.makeTypeSync().nameSync("foo").dataTypeSync(Type.String.class).indexedSync(Type.Vertex.class)
    .uniqueSync(Direction.BOTH, UniqCon.NO_LOCK).makePropertyKeySync();

Frank