Search code examples
orientdbtinkerpoptinkerpop-blueprint

dijkstra function of orientdb is not working with tinkerpop API


The below code is not giving the correct result, am I doing something wrong..?

OrientGraph graph = factory.getTx();

for (OrientVertex v : (Iterable<OrientVertex>) graph.command(
                new OCommandSQL("SELECT dijkstra(#97:1334, #97:1335, 'calculated_length') FROM STRUCTURE")).execute()) {
                      System.out.println("Path " + (ORID)v.getId());
                    }

When I execute the query directly, I am getting correct result. Thanks.


Solution

  • I used this code and it worked

    String query = "select expand(dijkstra) from (SELECT dijkstra(#21:0, #24:0, 'calculated_length') FROM STRUCTURE limit 1)";
    Iterable<OrientVertex> it = g.command( new OCommandSQL(query)).execute();
    for (OrientVertex v : it) { 
        System.out.println("Path " + (ORID)v.getId());     
    }
    

    Hope it helps