在neo4j节点属性值上添加索引

在neo4j节点属性值上添加索引,neo4j,Neo4j,我已将freebase dump导入neo4j。但由于数据库的大小,目前我面临get查询的问题。导入时,我刚刚创建了节点索引,并为每个节点创建了索引URI属性。对于每个节点,我将添加多个属性,如标签、内容、类型 props.put(URI_PROPERTY, subject.stringValue()); Long subjectNode = db.createNode(props); tmpIndex.put(subject.stringValue(), subjectNode); no

我已将freebase dump导入neo4j。但由于数据库的大小,目前我面临get查询的问题。导入时,我刚刚创建了节点索引,并为每个节点创建了索引URI属性。对于每个节点,我将添加多个属性,如标签、内容、类型

props.put(URI_PROPERTY, subject.stringValue());

Long subjectNode = db.createNode(props);

tmpIndex.put(subject.stringValue(), subjectNode);

nodeIndex.add(subjectNode, props);
现在我的密码查询是这样的。它们正在超时。我无法在label_en属性上添加索引。有人能帮忙吗

match (n)-[r*0..1]->(a) where n.label_en=~'Hibernate.*' return n, a
更新

BatchInserter db = BatchInserters.inserter("ttl.db", config);
BatchInserterIndexProvider indexProvider = new LuceneBatchInserterIndexProvider(db);
BatchInserterIndex index = indexProvider.nodeIndex("ttlIndex", MapUtil.stringMap("type", "exact"));
问题:当我在nodeindex中添加节点时,我添加了属性URI

props.put(URI_PROPERTY, subject.stringValue());
Long subjectNode = db.createNode(props);
nodeIndex.add(subjectNode, props);

在后面的代码中,我向节点添加了另一个属性(命名为label_en)。但我没有添加或更新nodeindex。因此,据我所知,lucene没有索引label_en属性。我的图形已经生成,因此我尝试在节点的label\u en属性上添加索引,因为我的查询位于label\u en上。

您的代码示例缺少创建索引的方式。但我很确定您正在使用的是基于ApacheLucene的遗留索引

您的密码查询正在使用正则表达式操作符
=~
。这不是使用传统索引的方式;这似乎迫使cypher忽略遗留索引,让java层在
label\u en
属性的每个可能值上运行该正则表达式

相反,你应该使用Cypher

对你来说,这看起来像这样:

START n=node:my_index_name("label_en:Hibernate.*")
MATCH (n)-[r*0..1]->(a)
RETURN n, a;
请注意字符串
label\u en:Hibernate.
-这是一个Lucene查询字符串,表示检查该特定字符串的属性名称。Cypher/neo4j没有解释这一点;它正在传递给Lucene

您的代码没有提供索引的名称。您必须将上面的
my_index_name
更改为创建旧索引时所命名的名称