Search code examples
gremlingraph-databasestinkerpopjanusgraphtinkerpop3

Apache Gremlin Filter returns empty when the vertex/edge is not present


Apache Gremlin Filter returns empty when the vertex/edge is not present.


g.V('12336', '4128', '155808').as("a").filter(
  __.V().has('end_time', p.gte('---DATE---')).where(P.neq("a"))).elementMap()

In the above query, __.V('155808').has('end_time', p.gte('---DATE---')) returns empty(), so the output also empyt.


Solution

  • The filter (or in this case you could equally use where) is just that a "filter". The values in the stream will only flow past the filter if the filter itself yields a result. By way of a simple example:

    gremlin> g.V(1).out().count()
    ==>242
    
    gremlin> g.V(1).filter(out().count().is(1))
    // No results
    
    gremlin> g.V(1).filter(out().count().is(242))
    ==>v[1]