com.atlassian.bonnie
Interface ILuceneConnection

All Known Implementing Classes:
ConcurrentLuceneConnection, LuceneConnection

public interface ILuceneConnection


Nested Class Summary
static interface ILuceneConnection.BatchUpdateAction
           
static interface ILuceneConnection.Configuration
          Provide defaults for a Lucene IndexWriter.
static interface ILuceneConnection.ReaderAction
           
static interface ILuceneConnection.SearcherAction
           
static interface ILuceneConnection.WriterAction
           
 
Field Summary
static ILuceneConnection.Configuration DEFAULT_CONFIGURATION
          The Bonnie default configuration.
 
Method Summary
 void close()
          Closes the reader and the writer.
 int getNumDocs()
          Returns the number of documents in the index.
 boolean isIndexCreated()
          Returns true if the index has been created.
 org.apache.lucene.search.IndexSearcher leakSearcher()
          Get the current Searcher from the ILuceneConnection.
 void optimize()
          Perform an optimize on the index.
 void recreateIndexDirectory()
          Create or recreate the underlying directory the index is contained in.
 void withBatchUpdate(ILuceneConnection.BatchUpdateAction action)
          Perform multiple writes to the index.
 void withDeleteAndWrites(ILuceneConnection.ReaderAction readerAction, ILuceneConnection.WriterAction action)
          Perform an Atomic delete and add.
 java.lang.Object withReader(ILuceneConnection.ReaderAction action)
          Idempotent operation.
 void withReaderAndDeletes(ILuceneConnection.ReaderAction action)
          Delete stuff in the index.
 void withSearch(ILuceneConnection.SearcherAction action)
           
 void withWriter(ILuceneConnection.WriterAction action)
          Add (write) documents to the index
 

Field Detail

DEFAULT_CONFIGURATION

static final ILuceneConnection.Configuration DEFAULT_CONFIGURATION
The Bonnie default configuration. Preserves backward compatability for old Confluence settings.

Method Detail

withSearch

void withSearch(ILuceneConnection.SearcherAction action)
                throws LuceneException
Throws:
LuceneException

withReader

java.lang.Object withReader(ILuceneConnection.ReaderAction action)
                            throws LuceneException
Idempotent operation. Just for querying, do not delete documents with this action use withReaderAndDeletes(ReaderAction) to perform index deletes.

Throws:
LuceneException

withReaderAndDeletes

void withReaderAndDeletes(ILuceneConnection.ReaderAction action)
                          throws LuceneException
Delete stuff in the index.

Throws:
LuceneException

withWriter

void withWriter(ILuceneConnection.WriterAction action)
                throws LuceneException
Add (write) documents to the index

Throws:
LuceneException

withDeleteAndWrites

void withDeleteAndWrites(ILuceneConnection.ReaderAction readerAction,
                         ILuceneConnection.WriterAction action)
                         throws LuceneException
Perform an Atomic delete and add. Shouldn't perform too many writes, for multiple writes use withBatchUpdate(com.atlassian.bonnie.ILuceneConnection.BatchUpdateAction) as it will use the batch mode configuration, speeding up the writes.

Throws:
LuceneException

withBatchUpdate

void withBatchUpdate(ILuceneConnection.BatchUpdateAction action)
Perform multiple writes to the index. Holds a writeLock on the index for the whole time, and will use the batch configuration settings.


optimize

void optimize()
              throws LuceneException
Perform an optimize on the index. Holds a writeLock and can take a long time (depending on the size of the index, how much optimization needs to be done... and whether a virus-checker is installed :) ).

Throws:
LuceneException

close

void close()
Closes the reader and the writer.


getNumDocs

int getNumDocs()
Returns the number of documents in the index.


isIndexCreated

boolean isIndexCreated()
Returns true if the index has been created. This means that the index directory itself exists AND has been initialised with the default required index files.

Returns:
true if the index exists, false otherwise.

recreateIndexDirectory

void recreateIndexDirectory()
Create or recreate the underlying directory the index is contained in. Blow away any indexes that currently live there.


leakSearcher

org.apache.lucene.search.IndexSearcher leakSearcher()
Get the current Searcher from the ILuceneConnection.

Do not forget to call the Searcher's close() method once the searcher is no longer neeeded.



Copyright © 2006-2008 Atlassian Software Systems Pty Ltd. All Rights Reserved.