Class IndexFileNames
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(string, string)), as well as generating file names from a segment name, generation and extension (FileNameFromGeneration(string, string, long), SegmentFileName(string, string, string)).
NOTE: extensions used by codecs are not listed here. You must interact with the Codec directly.Note
This API is for internal purposes only and might change in incompatible ways in the next release.
Inherited Members
Namespace: Lucene.Net.Index
Assembly: Lucene.Net.dll
Syntax
public sealed class IndexFileNames
Fields
CODEC_FILE_PATTERN
All files created by codecs much match this pattern (checked in SegmentInfo).
Declaration
public static readonly Regex CODEC_FILE_PATTERN
Field Value
Type | Description |
---|---|
Regex |
COMPOUND_FILE_ENTRIES_EXTENSION
Extension of compound file entries
Declaration
public static readonly string COMPOUND_FILE_ENTRIES_EXTENSION
Field Value
Type | Description |
---|---|
string |
COMPOUND_FILE_EXTENSION
Extension of compound file
Declaration
public static readonly string COMPOUND_FILE_EXTENSION
Field Value
Type | Description |
---|---|
string |
GEN_EXTENSION
Extension of gen file
Declaration
public static readonly string GEN_EXTENSION
Field Value
Type | Description |
---|---|
string |
INDEX_EXTENSIONS
This array contains all filename extensions used by
Lucene's index files, with one exception, namely the
extension made up from .s
+ a number.
Also note that Lucene's segments_N
files
do not have any filename extension.
Declaration
public static readonly string[] INDEX_EXTENSIONS
Field Value
Type | Description |
---|---|
string[] |
SEGMENTS
Name of the index segment file
Declaration
public static readonly string SEGMENTS
Field Value
Type | Description |
---|---|
string |
SEGMENTS_GEN
Name of the generation reference file name
Declaration
public static readonly string SEGMENTS_GEN
Field Value
Type | Description |
---|---|
string |
Methods
FileNameFromGeneration(string, string, long)
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>.
ext
is
not an empty string.
Declaration
public static string FileNameFromGeneration(string @base, string ext, long gen)
Parameters
Type | Name | Description |
---|---|---|
string | base | main part of the file name |
string | ext | extension of the filename |
long | gen | generation |
Returns
Type | Description |
---|---|
string |
GetExtension(string)
Return the extension (anything after the first '.'), or null if there is no '.' in the file name.
Declaration
public static string GetExtension(string filename)
Parameters
Type | Name | Description |
---|---|---|
string | filename |
Returns
Type | Description |
---|---|
string |
MatchesExtension(string, string)
Returns true
if the given filename ends with the given extension. One
should provide a pure extension, without '.'.
Declaration
public static bool MatchesExtension(string filename, string ext)
Parameters
Type | Name | Description |
---|---|---|
string | filename | |
string | ext |
Returns
Type | Description |
---|---|
bool |
ParseSegmentName(string)
Parses the segment name out of the given file name.
Declaration
public static string ParseSegmentName(string filename)
Parameters
Type | Name | Description |
---|---|---|
string | filename |
Returns
Type | Description |
---|---|
string | the segment name only, or filename if it does not contain a '.' and '_'. |
SegmentFileName(string, string, string)
Returns a file name that includes the given segment name, your own custom name and extension. The format of the filename is: <segmentName>(_<name>)(.<ext>).
NOTE: .<ext> is added to the result file name only ifext
is not empty.
NOTE: _<segmentSuffix> is added to the result file name only if
it's not the empty string
NOTE: all custom files should be named using this method, or
otherwise some structures may fail to handle them properly (such as if they
are added to compound files).
Declaration
public static string SegmentFileName(string segmentName, string segmentSuffix, string ext)
Parameters
Type | Name | Description |
---|---|---|
string | segmentName | |
string | segmentSuffix | |
string | ext |
Returns
Type | Description |
---|---|
string |
StripExtension(string)
Removes the extension (anything after the first '.'), otherwise returns the original filename.
Declaration
public static string StripExtension(string filename)
Parameters
Type | Name | Description |
---|---|---|
string | filename |
Returns
Type | Description |
---|---|
string |
StripSegmentName(string)
Strips the segment name out of the given file name. If you used SegmentFileName(string, 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).
Declaration
public static string StripSegmentName(string filename)
Parameters
Type | Name | Description |
---|---|---|
string | filename |
Returns
Type | Description |
---|---|
string | the filename with the segment name removed, or the given filename if it does not contain a '.' and '_'. |