has

Filter based on a particular vertex or edge label, property key, or property value.

The has() step is a filter step. It is the most common step used for graph traversals, since this step narrows the query to find particular vertices or edges with certain property keys or property values. Although the most performant method of using the has() step is to fully define with a label, property key and property value, several other options are available:

  • property key

  • property key and property value

  • vertex or edge label, property key and property value (recommended)

  • property key and predicate

Synopsis

has(
[ 'vertexLabel' | 'edgeLabel' , ]
{
[ predicate ('propertyKey\_value', ... ) ]
|
'propertyKey\_name', [ 'propertyKey\_value' ]
}
)

Examples

Find all items that use a property key name:

g.V().has('name'))

Find the item that has a property key name with a property value taco:

g.V().has('name', 'taco')

Find the item with a vertex label meal_item with a property key name and property value taco:

g.V().has('meal_item', 'name', 'taco')

Find the items have a property key name with property values taco or burrito:

g.V().has('name',within('taco','burrito'))

Was this helpful?

Give Feedback

How can we improve the documentation?

© 2024 DataStax | Privacy policy | Terms of use

Apache, Apache Cassandra, Cassandra, Apache Tomcat, Tomcat, Apache Lucene, Apache Solr, Apache Hadoop, Hadoop, Apache Pulsar, Pulsar, Apache Spark, Spark, Apache TinkerPop, TinkerPop, Apache Kafka and Kafka are either registered trademarks or trademarks of the Apache Software Foundation or its subsidiaries in Canada, the United States and/or other countries. Kubernetes is the registered trademark of the Linux Foundation.

General Inquiries: +1 (650) 389-6000, info@datastax.com