BatchInserter を使ったインデクシング

Neo4j Wiki から

This refers to the old index API. Please look at the integrated index framework instead.

This will cover the usage of LuceneIndexBatchInserter which relates to IndexService just as Batch Insert relates to GraphDatabaseService.

If you're looking for information about IndexService then go to Indexing with IndexService.

目次

[edit] Differences from IndexService

The LuceneIndexBatchInserter is designed for being performant when inserting large amounts of data with minimal lookups from the index during that time. You typically do a one-time batch insertion of a big amount of data and then when you have that data inserted you use an IndexService (together with a GraphDatabaseService) from there on. Just as the BatchInserter it doesn't support transactions or multiple threads, just to squeeze out more performance. You're expected to shut down the index nicely when you're done otherwise there's no guarantee that your data will be stored correctly.

[edit] Example

BatchInserter inserter = new BatchInserterImpl( "path/to/neo4j-db" );
LuceneIndexBatchInserter index = new LuceneIndexBatchInserterImpl( inserter );

Map<String, Object> properties = Collections.<String, Object>singletonMap( "name", "Thomas Andersson" );
long thomasId = inserter.createNode( properties );
index.index( thomasId, "name", properties.get( "name" ) );

[edit] Typical usage

You should use your LuceneIndexBatchInserter in a more restricted way than an IndexService to get it to perform better. Here are some pointers to get it right.

  • Try to avoid mixing reads with writes since there's a performance penalty in getNodes() each time the index has changed, due to the usage of the reopen functionality in lucene.
  • Have (as big as possible) phases where one phase is either only writes or only reads.
  • Use optimize() to speed up your read phase. It should only be used after a write phase when you've done all your writing for that phase.

[edit] Fulltext indexing

Just as LuceneFulltextIndexService is the "fulltext version" of LuceneIndexService, so is LuceneFulltextIndexBatchInserter the "fulltext version" of LuceneIndexBatchInserter.

Neo4j のサイト
ツールボックス