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), as well as generating file names from a segment name, generation and extension ( .fileNameFromGeneration, .segmentFileName).

NOTE: extensions used by codecs are not listed here. You must interact with the [ ] directly.

Properties

Link copied to clipboard

All files created by codecs must match this pattern (checked in SegmentInfo).

Link copied to clipboard

Name of pending index segment file

Link copied to clipboard
const val SEGMENTS: String

Name of the index segment file

Functions

Link copied to clipboard

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 .. If it's > 0, the file name is _..

NOTE: . is added to the name only if ext is not an empty string.

Link copied to clipboard
fun getExtension(filename: String): String?

Return the extension (anything after the first '.'), or null if there is no '.' in the file name.

Link copied to clipboard
fun matchesExtension(filename: String, ext: String): Boolean

Returns true if the given filename ends with the given extension. One should provide a pure extension, without '.'.

Link copied to clipboard
fun parseGeneration(filename: String): Long

Returns the generation from this file name, or 0 if there is no generation.

Link copied to clipboard

Parses the segment name out of the given file name.

Link copied to clipboard
fun segmentFileName(segmentName: String, segmentSuffix: String, ext: String): String

Returns a file name that includes the given segment name, your own custom name and extension. The format of the filename is: (_)(.).

Link copied to clipboard
fun stripExtension(filename: String): String

Removes the extension (anything after the first '.'), otherwise returns the original filename.

Link copied to clipboard

Strips the segment name out of the given file name. If you used .segmentFileName or .fileNameFromGeneration to create your files, then this method simply removes whatever comes before the first '.', or the second '_' (excluding both).