index - edge index

Synopsis

index('index_name').[outE('edgeLabel') | inE('edgeLabel') | bothE('edgeLabel')].by('propertykey_name').add()

Description

An edge index specifies an index that is built using an edge property key in DSE Graph. A vertex label must be specified, and edge indexes are only defined in relationship to a vertex label. The index name must be unique.

An edge index can be created using either outgoing edges (outE()) from a vertex label, incoming edges (inE()) from a vertex label, or both outgoing and incoming (bothE()). The last type, bothE(), is rarely used, but could be used in a situation where the index must track both the incoming and outgoing edges from a particular vertex label. An example would be a graph storing reviewers who can both be liked and like other reviewers. To search for reviewers who are liked and who like a particular reviewer, both incoming and outgoing edges would be searched.

Examples

Create an index ratedByStars with an outE edge label using the property key stars. The vertex label is specified as reviewer.

schema.vertexLabel('reviewer').index('ratedByStars').outE('rated').by('stars').add()

Create an index ratedByStars2Way with a bothE edge label using the property key year. The edge index allows queries that find both recipes with a certain year and reviewers who gave a review in a certain year.

schema.vertexLabel('recipe').index('byAuthOrRecipe').bothE('created').by('year').ifNotExists().add()

It can replace two indexes:

schema.vertexLabel('recipe').index('toRecipesRated').inE('rated').by('year').add()
schema.vertexLabel('reviewer').index('toReviewersWhoRated').outE('rated').by('year').add()

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