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
    • Field Detail

      • DEFAULT_CONFIGURATION

        static final ILuceneConnection.Configuration DEFAULT_CONFIGURATION
        The Bonnie default configuration. Preserves backward compatibility for old Confluence settings.
    • Method Detail

      • 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.
      • 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
      • closeWriter

        @Deprecated
        void closeWriter()
                  throws LuceneException
        Deprecated.
        since 8.1.1 without replacement, there is no real need to close writer while keeping reader open
        Closes the writer
        Throws:
        LuceneException
      • getNumDocs

        int getNumDocs()
        Returns the number of documents in the index.
      • 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