pShah
unread,May 11, 2012, 12:37:18 PM5/11/12Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to gremli...@googlegroups.com
Marko,
I started trying the "Query" feature, it is pretty cool.
I completely understand that this is a SNAPSHOT and everything is in flux, but I am just curious.
Sample Java code I tried with Query:
Iterable<Vertex> temp_V = new ArrayList();
IndexableGraph g = TinkerGraphFactory.createTinkerGraph();
Vertex lop = g.getIndex(Index.VERTICES, Vertex.class)
.get("name", "lop").iterator().next();
temp_V = lop.query().has("weight", 0.4f).vertices();
for(Vertex v: temp_V) {
System.out.println(v.getProperty("name"));
}
Output:
marko
josh
I just had few questions about its future implementations.
1. Will it have an option for "OR"
a) weight = 0.4f OR weight = 0.2f
2. Will it have an option for NULL or use if Exits
a) The use-case I am thinking of is assume that "weight" is either NULL or the property is not even specified.
I have done such a query with the GremlinPipeline
Sample Java code:
IndexableGraph g = TinkerGraphFactory.createTinkerGraph();
// If property exists use it else ignore it
List<String> output = new GremlinPipeline(g.getVertex(4))
.out("created")
.in("created")
.or(new PropertyFilterPipe("country", "USA", Tokens.mapFilter(T.eq)),
new PropertyFilterPipe("country", null, Tokens.mapFilter(T.eq))
)
.dedup()
.property("name")
.toList();
System.out.println(output);
Output: [josh, marko, peter]
3. Are there any plans of a QueryBuilder concept?
I was thinking of was something along the lines of Pipes.
Where all the Pipes are specified and then a "START" specified what Vertex to start from?
Or The same query can be applied at different point as appropriate?
Anyways this is great, I am looking for other great new things to try.
Thanks