com.atlassian.bonnie
Interface ILuceneConnection

All Known Implementing Classes:
ConcurrentLuceneConnection, LuceneConnection

public interface ILuceneConnection

A connection to a Lucene index. Supports reads, writes, searches, batch updates, and truncates.


Nested Class Summary
static interface ILuceneConnection.BatchUpdateAction
           
static interface ILuceneConnection.Configuration
          Provide configuration for the index writers used by implementations of this interface.
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()
          Deprecated. since 3.2 index creation is handled by the implementation, so this method now always returns true.
 org.apache.lucene.search.IndexSearcher leakSearcher()
          Deprecated. since 3.2 because the searcher shouldn't be leaked
 void optimize()
          Perform an optimize on the index.
 void recreateIndexDirectory()
          Create or recreate the underlying directory the index is contained in.
 void truncateIndex()
          Removes all documents from the index.
 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.
 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 compatibility for old Confluence settings.

Method Detail

withSearch

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

withReader

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.

Update actions performed within a batch update won't be visible to other readers or searchers until the batch is complete. Be aware this also applies to actions within a batch! That is, a read operation inside a batch will not see the changes made by earlier updates in that batch.


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()
           throws LuceneException
Closes the reader and the writer. Calling any method on the API after closing the connection will throw LuceneConnectionClosedException.

Throws:
LuceneException

getNumDocs

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


isIndexCreated

boolean isIndexCreated()
Deprecated. since 3.2 index creation is handled by the implementation, so this method now always returns true.

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

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()
Deprecated. since 3.2 because the searcher shouldn't be leaked

Get the current Searcher from the ILuceneConnection.

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

See Also:
withSearch(SearcherAction)

truncateIndex

void truncateIndex()
                   throws LuceneException
Removes all documents from the index.

Throws:
LuceneException - if there was a problem removing the index


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