与 OCommandSQL 的 Orientdb 匹配返回空顶点

Orientdb Match with OCommandSQL is returning null Vertices

我是 OrientDB 和蓝图的新手。我正在尝试使用 OrientDB Java API 执行简单的 MATCH 查询。下面是我的代码:

import com.orientechnologies.orient.core.sql.OCommandSQL;
import com.tinkerpop.blueprints.TransactionalGraph;
import com.tinkerpop.blueprints.Vertex;
import com.tinkerpop.blueprints.impls.orient.OrientGraph;

public class OrientApp {

@SuppressWarnings("unchecked")
public static void main(String[] args) {

    TransactionalGraph graph = new OrientGraph("remote:localhost/GratefulDeadConcerts", "admin", "admin");
    /*
     * Iterable<Vertex> vertices = (Iterable<Vertex>) (((OrientGraph) graph)
     * .command(new OCommandSQL(
     * "MATCH {class: Person, as: liker} -likes- {class:Person, as: like},{as:liker} -living_in- {class: City, where: (name='Bangalore')},{as:like} -living_in- {class: City, where: (name='Delhi')} RETURN liker.name,like.name"
     * )) .execute());
     */

    Iterable<Vertex> vertices = (Iterable<Vertex>) (((OrientGraph) graph)
            .command(new OCommandSQL("MATCH {class: Person, as: person} RETURN person")).execute());

    /*
     * Iterable<Vertex> vertices = (Iterable<Vertex>) (((OrientGraph) graph)
     * .command(new OCommandSQL("select * from person")).execute());
     */for (Vertex v : vertices) {
        System.out.println(v);
    }
    System.out.println(graph);
}

}

当我 运行 时,它在顶点中为我提供了空值。简单的 Select * from Person 工作正常并且 returns 不是空顶点。我正在使用 2.2.22 版本的 OrientDB。

任何链接或提示将不胜感激。谢谢!

关注 link 很有用 http://useof.org/java-open-source/com.orientechnologies.orient.core.metadata.schema.OSchemaProxy

实际上我们需要return $elements 匹配查询。

以下代码有效:

import com.orientechnologies.orient.core.sql.OCommandSQL;
import com.tinkerpop.blueprints.TransactionalGraph;
import com.tinkerpop.blueprints.Vertex;
import com.tinkerpop.blueprints.impls.orient.OrientGraph;

public class OrientApp {

@SuppressWarnings("unchecked")
public static void main(String[] args) {

    TransactionalGraph graph = new OrientGraph("remote:localhost/GratefulDeadConcerts", "admin", "admin");
    Iterable<Vertex> vertices = (Iterable<Vertex>) (((OrientGraph) graph)
            .command(new OCommandSQL("MATCH {class: Person, as: person, where: (age>10)} RETURN $elements"))
            .execute());

    for (Vertex v : vertices) {
        System.out.println(v.getProperty("age").toString());
    }
    System.out.println(graph);
}
}

希望对大家有所帮助。谢谢!