Skip to main content
All CollectionsData AnalysisGremlin training
Gremlin Training 5: Basic filtering steps - hasNot()
Gremlin Training 5: Basic filtering steps - hasNot()

Learn to use the hasNot()-step to filter components and references based on field values they do not have.

Kristine Marhilevica avatar
Written by Kristine Marhilevica
Updated over a year ago

Similar to how the has()-step can be used to filter away all components which do not have a value set for a particular field, the hasNot()-step can be used to filter away all components which do have a value set for a particular field. The following query finds all components of type "Person" where a Contact Email field has not been set.

g.V().hasLabel('Person').hasNot('contact_email')

Recall that when we learnt about the has()-step, we found that all the components of type "Person" had a filled out "Contact Email" field, except for the one named Tom Zaloga. This is confirmed by the query above.

hasNot()-step

Recall that the has()-step takes one, two or three arguments. The hasNot()-step does only take one argument. It can, for instance, not be used to filter away components which have a particular field value.

Did this answer your question?