orientdbtinkergraph

OrientDB Edge Index via Java


Is there a way using the Java API to access an edge index in OrientDB to determine whether a edge with a given label exists in between two known vertices?

Afaik tinkergraph is not exposing any methods for this?

I believe that Neo4j is providing an API like this:

graphDatabaseService.index().forRelationships("HAS_USER").get(key, valueOrNull, startNodeOrNull, endNodeOrNull)

Solution

  • You can call getEdges() from your vertex. Example:

    v1.getEdges(v2, Direction.BOTH, "HAS_USER");
    

    This is the JavaDoc:

    /**
       * (Blueprints Extension) Returns all the edges from the current Vertex to another one.
       *
       * @param iDestination
       *          The target vertex
       * @param iDirection
       *          The direction between OUT, IN or BOTH
       * @param iLabels
       *          Optional labels as Strings to consider
       * @return
       */
      public Iterable<Edge> getEdges(final OrientVertex iDestination, final Direction iDirection, final String... iLabels)