index - edge index

How to add an 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 reviewedByStars with an outE edge label using the property key stars. The vertex label is specified as person.
schema.vertexLabel('person').index('reviewedByStars').outE('reviewed').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('byPersonOrRecipe').bothE('created').by('year').ifNotExists().add()
It can replace two indexes:
schema.vertexLabel('recipe').index('toRecipesReviewed').inE('reviewed').by('year').add()
schema.vertexLabel('person').index('toPersonsWhoReviewed').outE('reviewed').by('year').add()