Class IndexFileNames


  • public final class IndexFileNames
    extends Object
    This class contains useful constants representing filenames and extensions used by lucene, as well as convenience methods for querying whether a file name matches an extension (matchesExtension), as well as generating file names from a segment name, generation and extension ( fileNameFromGeneration, segmentFileName).
    NOTE: This API is for internal purposes only and might change in incompatible ways in the next release.
    • Field Detail

      • DELETABLE

        public static final String DELETABLE
        Name of the index deletable file (only used in pre-lockless indices)
        See Also:
        Constant Field Values
      • TERMS_INDEX_EXTENSION

        public static final String TERMS_INDEX_EXTENSION
        Extension of terms index file
        See Also:
        Constant Field Values
      • FIELDS_INDEX_EXTENSION

        public static final String FIELDS_INDEX_EXTENSION
        Extension of stored fields index file
        See Also:
        Constant Field Values
      • VECTORS_FIELDS_EXTENSION

        public static final String VECTORS_FIELDS_EXTENSION
        Extension of vectors fields file
        See Also:
        Constant Field Values
      • VECTORS_DOCUMENTS_EXTENSION

        public static final String VECTORS_DOCUMENTS_EXTENSION
        Extension of vectors documents file
        See Also:
        Constant Field Values
      • VECTORS_INDEX_EXTENSION

        public static final String VECTORS_INDEX_EXTENSION
        Extension of vectors index file
        See Also:
        Constant Field Values
      • COMPOUND_FILE_EXTENSION

        public static final String COMPOUND_FILE_EXTENSION
        Extension of compound file
        See Also:
        Constant Field Values
      • COMPOUND_FILE_STORE_EXTENSION

        public static final String COMPOUND_FILE_STORE_EXTENSION
        Extension of compound file for doc store files
        See Also:
        Constant Field Values
      • SEPARATE_NORMS_EXTENSION

        public static final String SEPARATE_NORMS_EXTENSION
        Extension of separate norms
        See Also:
        Constant Field Values
      • INDEX_EXTENSIONS

        public static final String[] INDEX_EXTENSIONS
        This array contains all filename extensions used by Lucene's index files, with two exceptions, namely the extension made up from .f + a number and from .s + a number. Also note that Lucene's segments_N files do not have any filename extension.
      • INDEX_EXTENSIONS_IN_COMPOUND_FILE

        public static final String[] INDEX_EXTENSIONS_IN_COMPOUND_FILE
        File extensions that are added to a compound file (same as above, minus "del", "gen", "cfs").
      • STORE_INDEX_EXTENSIONS

        public static final String[] STORE_INDEX_EXTENSIONS
      • NON_STORE_INDEX_EXTENSIONS

        public static final String[] NON_STORE_INDEX_EXTENSIONS
      • COMPOUND_EXTENSIONS

        public static final String[] COMPOUND_EXTENSIONS
        File extensions of old-style index files
      • VECTOR_EXTENSIONS

        public static final String[] VECTOR_EXTENSIONS
        File extensions for term vector support
    • Constructor Detail

      • IndexFileNames

        public IndexFileNames()
    • Method Detail

      • fileNameFromGeneration

        public static final String fileNameFromGeneration​(String base,
                                                          String ext,
                                                          long gen)
        Computes the full file name from base, extension and generation. If the generation is -1, the file name is null. If it's 0, the file name is <base>.<ext>. If it's > 0, the file name is <base>_<gen>.<ext>.
        NOTE: .<ext> is added to the name only if ext is not an empty string.
        Parameters:
        base - main part of the file name
        ext - extension of the filename
        gen - generation
      • isDocStoreFile

        public static final boolean isDocStoreFile​(String fileName)
        Returns true if the provided filename is one of the doc store files (ends with an extension in STORE_INDEX_EXTENSIONS).
      • segmentFileName

        public static final String segmentFileName​(String segmentName,
                                                   String ext)
        Returns the file name that matches the given segment name and extension. This method takes care to return the full file name in the form <segmentName>.<ext>, therefore you don't need to prefix the extension with a '.'.
        NOTE: .<ext> is added to the result file name only if ext is not empty.
      • matchesExtension

        public static final boolean matchesExtension​(String filename,
                                                     String ext)
        Returns true if the given filename ends with the given extension. One should provide a pure extension, without '.'.
      • isSeparateNormsFile

        public static boolean isSeparateNormsFile​(String filename)
        Returns true if the given filename ends with the separate norms file pattern: SEPARATE_NORMS_EXTENSION + "[0-9]+".