1

Neo4j でのインデックスの使用/作成に問題があります。

私は大規模な挿入を行っているので、BatchInserter を使用します - import org.neo4j.unsafe.batchinsert.BatchInserter;

しかし - 挿入後、インデックスが表示されませんか?

次のようなインデックスを作成します。

BatchInserter inserter = BatchInserters.inserter( DB_CONNECTION_STRING );

Label personLabel = DynamicLabel.label( "Person" );

Label transactionLabel = DynamicLabel.label( "Transaction" );

BatchInserter inserter = inserter.createDeferredSchemaIndex( personLabel ).on( "personid" ).create();

BatchInserter inserter = inserter.createDeferredSchemaIndex( transactionLabel ).on( "txid" ).create();

次に、ノードを挿入します...

Map<String, Object> properties = new HashMap<>();

properties.put( "personid", myPersonID );

long nodeID = inserter.createNode( properties, personLabel );

バッチ インサーターは正常に終了します。

シャットダウン フックを登録しました。バッチ挿入とインデックスを完了する必要があります。

Runtime.getRuntime().addShutdownHook( new Thread() {
@Override
public void run() {
  inserter.shutdown();
} } );

最後に、Cypher クエリを試します。ただし、インデックスが存在しないと報告されます。

START n=node:Person(personid='12345')
MATCH (n)-[:MYEDGE]-(x) 
RETURN count(x);

結果:

STATEMENT_EXECUTION_ERROR: Index `Person` does not exist

どんな手掛かり??!

4

1 に答える 1

2

バッチ挿入中にスキーマ インデックスを作成していますが、Cypher クエリでは、個別に作成および更新する必要がある従来のインデックスを使用する START 句を使用します。クエリを次のように書き直してみてください。

MATCH (n:Person)-[:MYEDGE]-(x) 
WHERE n.persionid='12345' 
RETURN count(x)

その後、Cypher は適切なインデックスを自動的に選択して、クエリを高速化します。

于 2013-10-29T23:30:10.437 に答える