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?