Package 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
Fields Modifier and Type Field Description static String[]
COMPOUND_EXTENSIONS
File extensions of old-style index filesstatic String
COMPOUND_FILE_EXTENSION
Extension of compound filestatic String
COMPOUND_FILE_STORE_EXTENSION
Extension of compound file for doc store filesstatic String
DELETABLE
Name of the index deletable file (only used in pre-lockless indices)static String
DELETES_EXTENSION
Extension of deletesstatic String
FIELD_INFOS_EXTENSION
Extension of field infosstatic String
FIELDS_EXTENSION
Extension of stored fields filestatic String
FIELDS_INDEX_EXTENSION
Extension of stored fields index filestatic String
FREQ_EXTENSION
Extension of freq postings filestatic String
GEN_EXTENSION
Extension of gen filestatic 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 filestatic String
PLAIN_NORMS_EXTENSION
Extension of plain normsstatic String
PROX_EXTENSION
Extension of prox postings filestatic String
SEGMENTS
Name of the index segment filestatic String
SEGMENTS_GEN
Name of the generation reference file namestatic String
SEPARATE_NORMS_EXTENSION
Extension of separate normsstatic String[]
STORE_INDEX_EXTENSIONS
static String
TERMS_EXTENSION
Extension of terms filestatic String
TERMS_INDEX_EXTENSION
Extension of terms index filestatic String[]
VECTOR_EXTENSIONS
File extensions for term vector supportstatic String
VECTORS_DOCUMENTS_EXTENSION
Extension of vectors documents filestatic String
VECTORS_FIELDS_EXTENSION
Extension of vectors fields filestatic String
VECTORS_INDEX_EXTENSION
Extension of vectors index file
-
Constructor Summary
Constructors Constructor Description IndexFileNames()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description 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 inSTORE_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.
-
-
-
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'ssegments_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
-
-
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 ifext
is not an empty string.- Parameters:
base
- main part of the file nameext
- extension of the filenamegen
- 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 inSTORE_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 ifext
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 usedsegmentFileName(java.lang.String, java.lang.String)
orfileNameFromGeneration(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]+"
.
-
-