Chinnadurai_V
Chinnadurai_V

Reputation: 90

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.

Upvotes: 0

Views: 108

Answers (1)

Alessandro Rota
Alessandro Rota

Reputation: 3570

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

Upvotes: 3

Related Questions