Interface ILuceneConnection
-
- All Known Implementing Classes:
LuceneConnection
public interface ILuceneConnection
A connection to a Lucene index. Supports reads, writes, searches, batch updates, and truncates.- Since:
- 8.0
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description 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.SearcherWithTokenAction<T>
static interface
ILuceneConnection.WriterAction
-
Field Summary
Fields Modifier and Type Field Description static ILuceneConnection.Configuration
DEFAULT_CONFIGURATION
The Bonnie default configuration.
-
Method Summary
All Methods Instance Methods Abstract Methods Deprecated Methods Modifier and Type Method Description void
close()
Closes the reader and the writer.void
closeWriter()
Deprecated.since 8.1.1 without replacement, there is no real need to close writer while keeping reader openint
getNumDocs()
Returns the number ofdocuments
in the index.long
getSizeInBytes()
Get total size of the index in bytes.void
optimize()
Perform an optimize on the index.void
reset(Runnable resetAction)
Closes the reader and the writer and create new ones.void
snapshot(org.apache.lucene.store.Directory destDir)
Allows taking a snapshot of the index.void
truncateIndex()
Removes all documents from the index.void
withBatchUpdate(ILuceneConnection.BatchUpdateAction action)
Perform multiple writes to the index.Object
withReader(ILuceneConnection.ReaderAction action)
Idempotent operation.void
withSearch(ILuceneConnection.SearcherAction action)
<T> T
withSearcher(long searchToken, ILuceneConnection.SearcherWithTokenAction<T> action)
Perform a search with the specified search token.<T> T
withSearcher(ILuceneConnection.SearcherWithTokenAction<T> action)
Perform a search that can be later continued via the search token passed toILuceneConnection.SearcherWithTokenAction.perform(IndexSearcher, long)
.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
-
withSearcher
<T> T withSearcher(ILuceneConnection.SearcherWithTokenAction<T> action)
Perform a search that can be later continued via the search token passed to
ILuceneConnection.SearcherWithTokenAction.perform(IndexSearcher, long)
.You may want to continue the search by requesting the next page of results, or refining the search with additional parameters. The token guarantees that the search will be conducted on a particular version of the index.
- Type Parameters:
T
- the return type of the searcher action callback- Parameters:
action
- the search action to perform- Returns:
- result of the search
-
withSearcher
<T> T withSearcher(long searchToken, ILuceneConnection.SearcherWithTokenAction<T> action) throws SearchTokenExpiredException
Perform a search with the specified search token.- Type Parameters:
T
- the return type of the searcher action callback- Parameters:
searchToken
- a search token that identifies a version of the index to search.action
- the search action to perform- Returns:
- result of the search
- Throws:
SearchTokenExpiredException
- if the specified search token has expired. Clients should report the error to the user and / or retry the search with a new token.
-
withReader
Object withReader(ILuceneConnection.ReaderAction action) throws LuceneException
Idempotent operation. Just for querying, do not delete documents with this action. UsewithWriter(WriterAction)
to perform index deletes.- Throws:
LuceneException
-
withWriter
void withWriter(ILuceneConnection.WriterAction action) throws LuceneException
Add (write) documents to the index- 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 thebatch 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 throwLuceneConnectionClosedException
.- Throws:
LuceneException
-
closeWriter
@Deprecated void closeWriter() throws LuceneException
Deprecated.since 8.1.1 without replacement, there is no real need to close writer while keeping reader openCloses the writer- Throws:
LuceneException
-
getNumDocs
int getNumDocs()
Returns the number ofdocuments
in the index.
-
getSizeInBytes
long getSizeInBytes() throws IOException
Get total size of the index in bytes.- Returns:
- size of the index in bytes
- Throws:
IOException
- Since:
- 8.8.0
-
truncateIndex
void truncateIndex() throws LuceneException
Removes all documents from the index.- Throws:
LuceneException
- if there was a problem removing the index
-
snapshot
void snapshot(org.apache.lucene.store.Directory destDir) throws IOException
Allows taking a snapshot of the index.- Parameters:
destDir
- directory in which the snapshot should be saved- Throws:
IOException
- Since:
- 6.2
-
reset
void reset(Runnable resetAction) throws LuceneException
Closes the reader and the writer and create new ones.- Parameters:
resetAction
- action that should be executed before the reset- Throws:
LuceneException
- Since:
- 6.5
-
-