Search code examples
gremlinamazon-neptune

Gremlin set property operations


I have below mentioned dataset

g.addV('testvertex').property(id, 'user1').property(set, 'states','TX').property(set,'states','CA').property(set,'states','AL').property(set,'states','AK')
  1. how do I find the count of states 'user1' has lived in?
  2. if 'user1' ever lived in 'IA' and 'KS' ?
  3. how do i drop 'TX' from states set ?

Solution

  • how do I find the count of states 'user1' has lived in?

    g.V().values('states').count()
    

    if 'user1' ever lived in 'IA' and 'KS' ?

    g.V().has(id,'user1').has('states', within('IA','KS'))
    

    how do i drop 'TX' from states set ?

    g.V().has(id,'user1').
      properties('states').hasValue('TX').drop()