Hi,
> I would like to write a Gremlin Query via the Gremlin Rest plugin to count
> the number of Nodes with a certain property.
>
> Some pseudo code:
> g.aidx-agency-key('key','agency').count()
>
> So, my questions are.
> How do I create the automatic index initially through the gremlin rest plugin
> or rest api directly?
To create an AutomaticIndex, do:
g.createAutomaticIndex('myIndex', Vertex.class, null) // null can be a
Set<String> of keys to automatically index -- null means, index all keys.
If the graph already existed prior to creating the AutomaticIndex, then you
will need to reIndex the index.
AutomaticIndexHelper.reIndex(g.idx('myIndex'), g.V)
See the Blueprints API for more information:
http://tinkerpop.com/maven2/com/tinkerpop/blueprints/blueprints/0.7/api/
> and what would the gremlin query look like once the index is indeed created?
Well, you can do this with your AutomaticIndex.
g.idx('myIndex').count('myProperty', myValue)
Tada!
If you don't want to create an index, you can do this with a global iteration
as such:
g.V[[myProperty:myValue]].count()
Hope that helps,
Marko.
http://markorodriguez.com
_______________________________________________
Neo4j mailing list
[email protected]
https://lists.neo4j.org/mailman/listinfo/user