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
どんな手掛かり??!