org.neo4j.index.lucene
Interface LuceneIndexBatchInserter

All Known Implementing Classes:
LuceneFulltextIndexBatchInserter, LuceneIndexBatchInserterImpl

public interface LuceneIndexBatchInserter

The "batch inserter" version of LuceneIndexService. It should be used with a BatchInserter and stores the indexes in the same format as LuceneIndexService. It's optimized for large chunks of either reads or writes. So try to avoid mixed reads and writes because there's a slight overhead to go from read mode to write mode (the "mode" is per key and will not affect other keys) See more information at http://wiki.neo4j.org/content/Indexing_with_BatchInserter


Method Summary
 IndexService getIndexService()
           
 IndexHits<Long> getNodes(String key, Object value)
          Queries the lucene index for hits given the key and value .
 long getSingleNode(String key, Object value)
           
 void index(long node, String key, Object value)
          Adds an entry to the index.
 void optimize()
          Performs a Lucene optimize on the index files.
 void shutdown()
          Shuts down this index and closes its underlying lucene index files.
 

Method Detail

index

void index(long node,
           String key,
           Object value)
Adds an entry to the index.

Parameters:
node - the node to associate with the value in the index with name key.
key - which index to put it in.
value - the value to associate node with.

shutdown

void shutdown()
Shuts down this index and closes its underlying lucene index files. If this isn't called before the JVM dies then there's no guarantee that the indices are stored correctly on disk.


getNodes

IndexHits<Long> getNodes(String key,
                         Object value)
Queries the lucene index for hits given the key and value . The usage of getNodes(String, Object), getSingleNode(String, Object) should be as separated as possible from the usage of index(long, String, Object). so that the performance penalty gets as small as possible. Also see optimize() for separation between writes and reads.

Parameters:
key - the index.
value - the value to query for.
Returns:
the hits for the query.

optimize

void optimize()
Performs a Lucene optimize on the index files. Do not use this too often as it comes with a severe performance penalty. It optimizes the Lucene index files so that consecutive queries will be faster. So the optimal usage is to index all of your data that you would like to index (with minimal amount of reads during that time). When you're done indexing and move into a phase where you'd want to use the index for lookups (maybe for creating relationships between nodes) you can call this method so that your queries will be faster than they would otherwise be.

See Also:
IndexWriter.optimize()

getSingleNode

long getSingleNode(String key,
                   Object value)
Parameters:
key - the index key to query.
value - the value to query for.
Returns:
the node id or -1 if no node found. It will throw a RuntimeException if there's more than one node in the result.

getIndexService

IndexService getIndexService()
Returns:
this batch inserter index wrapped in a IndexService interface for convenience. Goes well with an instance from BatchInserter.getGraphDbService().


Copyright © 2010 Neo4j. All Rights Reserved.