orientdb

Is there a way to force OrientDB to use indices when searching across embedded and linked documents?


I learned that OrientDB would allow me to store edges to other documents and thus would not need join statements. I created the appropriate indices, tested this, and noticed the following:

  1. After unwinding an embedded list, all queries afterward do not use indices.
  2. Traversing a graph with a WHERE clause does not use indices.
  3. Queries that pass through an edge (link) do not use indices.
  4. Only queries that access top level fields with primitive values like strings, floats use indices.

Is there a way to force the use of indices in those queries?


Solution

  • OrientDB support mainly indexes on basic properties like you said it works well on the top level fields of document, anyway it does support as well indexes for collections of simple types, like for example a java List<String>.

    It is possible to use indexes to traverse graph relationship but is a bit convoluted, because you need to create indexes for the whole set of structures of the path, for example a condition :

    out('Friend').name="John"

    to use index, it need indexes on the whole path like:

    create index vertex_out_friend on vertex(out_friend) not_unique;
    create index friend_out on Friend(out) not_unique;
    create index vertex_name on vertex(name) not_unque;
    

    vertex == stand as the vertex class of your vertex Friend == stand as the edge class of your edge

    I hope this help