## org.apache.lucene.index
Class IndexFileNames

    java.lang.Object
      org.apache.lucene.index.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 Summary
`static String[]` `COMPOUND_EXTENSIONS` File extensions of old-style index files
`static String` `COMPOUND_FILE_EXTENSION` Extension of compound file
`static String` `COMPOUND_FILE_STORE_EXTENSION` Extension of compound file for doc store files
`static String` `DELETABLE` Name of the index deletable file (only used in pre-lockless indices)
`static String` `DELETES_EXTENSION` Extension of deletes
`static String` `FIELD_INFOS_EXTENSION` Extension of field infos
`static String` `FIELDS_EXTENSION` Extension of stored fields file
`static String` `FIELDS_INDEX_EXTENSION` Extension of stored fields index file
`static String` `FREQ_EXTENSION` Extension of freq postings file
`static String` `GEN_EXTENSION` Extension of gen file
`static 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.
`static String[]` `INDEX_EXTENSIONS_IN_COMPOUND_FILE` File extensions that are added to a compound file (same as above, minus "del", "gen", "cfs").
`static String[]` `NON_STORE_INDEX_EXTENSIONS`
`static String` `NORMS_EXTENSION` Extension of norms file
`static String` `PLAIN_NORMS_EXTENSION` Extension of plain norms
`static String` `PROX_EXTENSION` Extension of prox postings file
`static String` `SEGMENTS` Name of the index segment file
`static String` `SEGMENTS_GEN` Name of the generation reference file name
`static String` `SEPARATE_NORMS_EXTENSION` Extension of separate norms
`static String[]` `STORE_INDEX_EXTENSIONS`
`static String` `TERMS_EXTENSION` Extension of terms file
`static String` `TERMS_INDEX_EXTENSION` Extension of terms index file
`static String[]` `VECTOR_EXTENSIONS` File extensions for term vector support
`static String` `VECTORS_DOCUMENTS_EXTENSION` Extension of vectors documents file
`static String` `VECTORS_FIELDS_EXTENSION` Extension of vectors fields file
`static String` `VECTORS_INDEX_EXTENSION` Extension of vectors index file

Constructor Summary
`IndexFileNames()`

Method Summary
`static String` `fileNameFromGeneration(String base, String ext, long gen)` Computes the full file name from base, extension and generation.
`static 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`).
`static boolean` `isSeparateNormsFile(String filename)` Returns true if the given filename ends with the separate norms file pattern: `SEPARATE_NORMS_EXTENSION + "[0-9]+"`.
`static boolean` `matchesExtension(String filename, String ext)` Returns true if the given filename ends with the given extension.
`static String` `segmentFileName(String segmentName, String ext)` Returns the file name that matches the given segment name and extension.
`static String` `stripSegmentName(String filename)` Strips the segment file name out of the given one.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### SEGMENTS

    public static final String SEGMENTS

  Name of the index segment file

  See Also:
    Constant Field Values

### SEGMENTS_GEN

    public static final String SEGMENTS_GEN

  Name of the generation reference file name

  See Also:
    Constant Field Values

### DELETABLE

    public static final String DELETABLE

  Name of the index deletable file (only used in pre-lockless indices)

  See Also:
    Constant Field Values

### NORMS_EXTENSION

    public static final String NORMS_EXTENSION

  Extension of norms file

  See Also:
    Constant Field Values

### FREQ_EXTENSION

    public static final String FREQ_EXTENSION

  Extension of freq postings file

  See Also:
    Constant Field Values

### PROX_EXTENSION

    public static final String PROX_EXTENSION

  Extension of prox postings file

  See Also:
    Constant Field Values

### TERMS_EXTENSION

    public static final String TERMS_EXTENSION

  Extension of terms file

  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

### FIELDS_EXTENSION

    public static final String FIELDS_EXTENSION

  Extension of stored fields 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

### DELETES_EXTENSION

    public static final String DELETES_EXTENSION

  Extension of deletes

  See Also:
    Constant Field Values

### FIELD_INFOS_EXTENSION

    public static final String FIELD_INFOS_EXTENSION

  Extension of field infos

  See Also:
    Constant Field Values

### PLAIN_NORMS_EXTENSION

    public static final String PLAIN_NORMS_EXTENSION

  Extension of plain norms

  See Also:
    Constant Field Values

### SEPARATE_NORMS_EXTENSION

    public static final String SEPARATE_NORMS_EXTENSION

  Extension of separate norms

  See Also:
    Constant Field Values

### GEN_EXTENSION

    public static final String GEN_EXTENSION

  Extension of gen file

  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 '.'.

### stripSegmentName

    public static final String stripSegmentName(String filename)

  Strips the segment file name out of the given one. If you used `segmentFileName(java.lang.String, java.lang.String)` or `fileNameFromGeneration(java.lang.String, java.lang.String, long)` to create your files, then this method simply removes whatever comes before the first '.', or the second '_' (excluding both), in case of deleted docs.

  Returns:
    the filename with the segment name removed, or the given filename if it does not contain a '.' and '_'.

### 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]+"`.