Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/neo4j/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
neo4j中的模式索引_Neo4j - Fatal编程技术网

neo4j中的模式索引

neo4j中的模式索引,neo4j,Neo4j,我使用以下代码在数据库中创建了模式索引 index_1 = schema.indexFor(DynamicLabel.label("USER")).on("username").create(); index_2 = schema.indexFor(DynamicLabel.label("UNIVERSITY")).on("university_name").create(); index_3 = schema.indexFor(DynamicLabel.label("COLLEGE")).on

我使用以下代码在数据库中创建了模式索引

index_1 = schema.indexFor(DynamicLabel.label("USER")).on("username").create();
index_2 = schema.indexFor(DynamicLabel.label("UNIVERSITY")).on("university_name").create();
index_3 = schema.indexFor(DynamicLabel.label("COLLEGE")).on("college_name").create();
当我第一次启动数据库时,索引工作正常。然后我在数据库中插入一些节点,然后查询数据库以返回标签为“UNIVERSITY”的节点。第一次,它工作完美,并向我展示了正确的结果。我编写了以下代码来显示标签为“UNIVERSITY”的所有节点

try(事务tx=graphdb.beginTx();)
{
ResourceIterator univ=graphdb.findNodesByBeland属性(DynamicLabel.label(“大学”),“大学名称”,大学名称).iterator();
while(大学hasNext())
{
System.out.println(“学院节点”+id++++“+univ.next().getProperty(“名称”));
}
关闭大学();
成功();
}
然后我关闭了数据库。但下次当我启动数据库并查询数据库以返回标签为“UNIVERSITY”的节点时,它不会返回节点。univ.hasNext()变为false,在循环时不执行


请告诉我我做错了什么???

您是否使用了相同的数据库目录?您使用了哪个Neo4j版本?是的,我使用的是相同的数据库目录。我使用的是neo4j 2.0您能查询模式中的索引定义吗?您是否可以尝试使用类似于
MATCH(n:UNIVERSITY)return count(*)和
MATCH(n:UNIVERSITY{UNIVERSITY\u name='xxx'})的cypher语句返回n
是,我使用以下语句查询了架构中的索引定义//迭代器用户=schema.getIndexes().Iterator();//System.out.println(schema.getIndexState(users.next()).toString());它返回所有三个索引定义。实际上,我使用JavaAWT脚本作为前端将数据插入数据库。这会产生任何问题吗?不会的。你只需要确保你的操作保持在同一个线程中,并且你不会意外地在事件线程和后台线程中使用相同的事务。
try (Transaction tx = graphdb.beginTx();)
{
ResourceIterator <Node> univ = graphdb.findNodesByLabelAndProperty(DynamicLabel.label("UNIVERSITY"), "university_name", UNIV_NAME).iterator();

while(univ.hasNext())
 {
    System.out.println("College node "+id++ + " " + univ.next().getProperty("name"));

 }

univ.close();
tx.success();
}