如何读取neo4j中节点的属性?

如何读取neo4j中节点的属性?,neo4j,Neo4j,我对neo4j非常陌生,并且构建了由>10M节点组成的db。在查询操作期间,我希望通过使用节点的两个属性来查找节点。例如:节点-name:xxx姓氏:yyy id:1在查询操作期间,我需要获取节点id哪个名称:xxx,姓氏:yyy。如何使用java查询(而不是cypher)实现?并且将有多个具有给定属性的条目 下面是一个如何查找ID的示例: GraphDatabaseService database; Label label = DynamicLabel.label("your_label_n

我对
neo4j
非常陌生,并且构建了由>10M节点组成的db。在查询操作期间,我希望通过使用节点的两个属性来查找节点。例如:节点-
name:xxx姓氏:yyy id:1
在查询操作期间,我需要获取节点
id
哪个
名称:xxx,姓氏:yyy
。如何使用java查询(而不是cypher)实现?并且将有多个具有给定属性的条目

下面是一个如何查找ID的示例:

GraphDatabaseService database;

Label label = DynamicLabel.label("your_label_name");
String propertyId = "id";
String propertyName = "name";
String propertySurname = "surname";

public Set<Node> getIdsForPeople(Set<Person> people) {

    Set<String> ids = new HashSet<>();

    try(Transaction tx = database.beginTx()) {
        for (Person person in people) {
            Node node = database.findNode(label, propertyName, person.getName());

            if (node.hasProperty(propertySurname)) {
                if (node.getProperty(propertySurname) == person.getSurname()) {
                    String id = node.getProperty(propertyId).toString();

                    ids.add(id);
                }
            }
        }

        tx.success();
    }

    return ids;
}
范例

Set<Person> people = new HashSet<Person>(){{
    add(new Person("xxx1", "yyy1"));
    add(new Person("xxx2", "yyy2"));
    add(new Person("xxx3", "yyy3");
    add(new Person("xxx4", "yyy4");
}};

Set<String> ids = getIdsForPeople(people);
Set people=newhashset(){{
添加(新人员(“xxx1”、“yyy1”);
添加(新人员(“xxx2”、“yyyy2”);
添加(新人员(“xxx3”、“yyyy3”);
添加(新人员(“xxx4”、“YYYY4”);
}};
设置id=getIdsForPeople(人);

如果有多个条目具有给定的规格,我该怎么办?
Set<Person> people = new HashSet<Person>(){{
    add(new Person("xxx1", "yyy1"));
    add(new Person("xxx2", "yyy2"));
    add(new Person("xxx3", "yyy3");
    add(new Person("xxx4", "yyy4");
}};

Set<String> ids = getIdsForPeople(people);