public final class

IndexFileNames

extends Object
java.lang.Object
   ↳ org.apache.lucene.index.IndexFileNames

Class Overview

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

Summary

Constants
String COMPOUND_FILE_EXTENSION Extension of compound file
String COMPOUND_FILE_STORE_EXTENSION Extension of compound file for doc store files
String DELETABLE Name of the index deletable file (only used in pre-lockless indices)
String DELETES_EXTENSION Extension of deletes
String FIELDS_EXTENSION Extension of stored fields file
String FIELDS_INDEX_EXTENSION Extension of stored fields index file
String FIELD_INFOS_EXTENSION Extension of field infos
String FREQ_EXTENSION Extension of freq postings file
String GEN_EXTENSION Extension of gen file
String NORMS_EXTENSION Extension of norms file
String PLAIN_NORMS_EXTENSION Extension of plain norms
String PROX_EXTENSION Extension of prox postings file
String SEGMENTS Name of the index segment file
String SEGMENTS_GEN Name of the generation reference file name
String SEPARATE_NORMS_EXTENSION Extension of separate norms
String TERMS_EXTENSION Extension of terms file
String TERMS_INDEX_EXTENSION Extension of terms index file
String VECTORS_DOCUMENTS_EXTENSION Extension of vectors documents file
String VECTORS_FIELDS_EXTENSION Extension of vectors fields file
String VECTORS_INDEX_EXTENSION Extension of vectors index file
Fields
public static final String[] COMPOUND_EXTENSIONS File extensions of old-style index files
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.
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").
public static final String[] NON_STORE_INDEX_EXTENSIONS
public static final String[] STORE_INDEX_EXTENSIONS
public static final String[] VECTOR_EXTENSIONS File extensions for term vector support
Public Constructors
IndexFileNames()
Public Methods
final static String fileNameFromGeneration(String base, String ext, long gen)
Computes the full file name from base, extension and generation.
final 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]+".
final static boolean matchesExtension(String filename, String ext)
Returns true if the given filename ends with the given extension.
final static String segmentFileName(String segmentName, String ext)
Returns the file name that matches the given segment name and extension.
final static String stripSegmentName(String filename)
Strips the segment file name out of the given one.
[Expand]
Inherited Methods
From class java.lang.Object

Constants

public static final String COMPOUND_FILE_EXTENSION

Extension of compound file

Constant Value: "cfs"

public static final String COMPOUND_FILE_STORE_EXTENSION

Extension of compound file for doc store files

Constant Value: "cfx"

public static final String DELETABLE

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

Constant Value: "deletable"

public static final String DELETES_EXTENSION

Extension of deletes

Constant Value: "del"

public static final String FIELDS_EXTENSION

Extension of stored fields file

Constant Value: "fdt"

public static final String FIELDS_INDEX_EXTENSION

Extension of stored fields index file

Constant Value: "fdx"

public static final String FIELD_INFOS_EXTENSION

Extension of field infos

Constant Value: "fnm"

public static final String FREQ_EXTENSION

Extension of freq postings file

Constant Value: "frq"

public static final String GEN_EXTENSION

Extension of gen file

Constant Value: "gen"

public static final String NORMS_EXTENSION

Extension of norms file

Constant Value: "nrm"

public static final String PLAIN_NORMS_EXTENSION

Extension of plain norms

Constant Value: "f"

public static final String PROX_EXTENSION

Extension of prox postings file

Constant Value: "prx"

public static final String SEGMENTS

Name of the index segment file

Constant Value: "segments"

public static final String SEGMENTS_GEN

Name of the generation reference file name

Constant Value: "segments.gen"

public static final String SEPARATE_NORMS_EXTENSION

Extension of separate norms

Constant Value: "s"

public static final String TERMS_EXTENSION

Extension of terms file

Constant Value: "tis"

public static final String TERMS_INDEX_EXTENSION

Extension of terms index file

Constant Value: "tii"

public static final String VECTORS_DOCUMENTS_EXTENSION

Extension of vectors documents file

Constant Value: "tvd"

public static final String VECTORS_FIELDS_EXTENSION

Extension of vectors fields file

Constant Value: "tvf"

public static final String VECTORS_INDEX_EXTENSION

Extension of vectors index file

Constant Value: "tvx"

Fields

public static final String[] COMPOUND_EXTENSIONS

File extensions of old-style index files

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.

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").

public static final String[] NON_STORE_INDEX_EXTENSIONS

public static final String[] STORE_INDEX_EXTENSIONS

public static final String[] VECTOR_EXTENSIONS

File extensions for term vector support

Public Constructors

public IndexFileNames ()

Public Methods

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

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

public static boolean isSeparateNormsFile (String filename)

Returns true if the given filename ends with the separate norms file pattern: SEPARATE_NORMS_EXTENSION + "[0-9]+".

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

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.

public static final String stripSegmentName (String filename)

Strips the segment file name out of the given one. If you used segmentFileName(String, String) or fileNameFromGeneration(String, 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 '_'.