Interface IndexAccessor

  • All Known Implementing Classes:
    IndexAccessorImpl

    public interface IndexAccessor
    The entry point for low-level I/O operations on a Lucene index.

    Used to retrieve the index writer and index reader in particular.

    • Method Detail

      • createIndexIfMissing

        void createIndexIfMissing()
        Checks whether the index exists (on disk, ...), and creates it if necessary.
      • validateIndexExists

        void validateIndexExists()
        Checks whether the index exists (on disk, ...), and throws an exception if it doesn't.
      • dropIndexIfExisting

        void dropIndexIfExisting()
        Checks whether the index exists (on disk, ...), and drops it if it exists.
      • commit

        void commit()
        Commits the underlying index writer, if any.
      • commitOrDelay

        void commitOrDelay()
        Commits the underlying index writer, if any, or delay the commit if a commit happened recently and configuration requires to wait longer between two commits.
      • refresh

        void refresh()
        Refreshes the underlying index readers.
      • mergeSegments

        void mergeSegments()
        Merge segments files.
      • getIndexReader

        org.apache.lucene.index.DirectoryReader getIndexReader()
                                                        throws IOException
        Returns:
        The most up-to-date index reader available.
        Throws:
        IOException
      • cleanUpAfterFailure

        void cleanUpAfterFailure​(Throwable throwable,
                                 Object failingOperation)
        Closes, drops and re-creates any cached resources: index writers, index readers.

        Should be used to clean up the accessor upon write or commit failure, passing an exception with as much information as possible (operation, document ID, ...).

        Parameters:
        throwable - The failure.
        failingOperation - The operation that failed.
      • computeSizeInBytes

        long computeSizeInBytes()
        Returns:
        The size of the index on its storage support, in bytes.