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 ClassesModifier and TypeInterfaceDescriptionstatic interface
static interface
Provide configuration for the index writers used by implementations of this interface.static interface
static interface
static interface
static interface
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final ILuceneConnection.Configuration
The Bonnie default configuration. -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
Closes the reader and the writer.void
Deprecated.since 8.1.1 without replacement, there is no real need to close writer while keeping reader openint
Returns the number ofdocuments
in the index.long
Get total size of the index in bytes.void
optimize()
Perform an optimize on the index.void
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
Removes all documents from the index.void
Perform multiple writes to the index.Idempotent operation.void
<T> T
withSearcher
(long searchToken, ILuceneConnection.SearcherWithTokenAction<T> action) Perform a search with the specified search token.<T> T
Perform a search that can be later continued via the search token passed toILuceneConnection.SearcherWithTokenAction.perform(IndexSearcher, long)
.void
Add (write) documents to the index
-
Field Details
-
DEFAULT_CONFIGURATION
The Bonnie default configuration. Preserves backward compatibility for old Confluence settings.
-
-
Method Details
-
withSearch
- Throws:
LuceneException
-
withSearcher
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
Idempotent operation. Just for querying, do not delete documents with this action. UsewithWriter(WriterAction)
to perform index deletes.- Throws:
LuceneException
-
withWriter
Add (write) documents to the index- Throws:
LuceneException
-
withBatchUpdate
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
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
Closes the reader and the writer. Calling any method on the API after closing the connection will throwLuceneConnectionClosedException
.- Throws:
LuceneException
-
closeWriter
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
Get total size of the index in bytes.- Returns:
- size of the index in bytes
- Throws:
IOException
- Since:
- 8.8.0
-
truncateIndex
Removes all documents from the index.- Throws:
LuceneException
- if there was a problem removing the index
-
snapshot
Allows taking a snapshot of the index.- Parameters:
destDir
- directory in which the snapshot should be saved- Throws:
IOException
- Since:
- 6.2
-
reset
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
-