Class PerFieldPostingsFormat
- java.lang.Object
-
- org.apache.lucene.codecs.PostingsFormat
-
- org.apache.lucene.codecs.perfield.PerFieldPostingsFormat
-
- All Implemented Interfaces:
NamedSPILoader.NamedSPI
public abstract class PerFieldPostingsFormat extends PostingsFormat
Enables per field postings support.Note, when extending this class, the name (
PostingsFormat.getName()
) is written into the index. In order for the field to be read, the name must resolve to your implementation viaPostingsFormat.forName(String)
. This method uses Java'sService Provider Interface
to resolve format names.Files written by each posting format have an additional suffix containing the format name. For example, in a per-field configuration instead of _1.prx filenames would look like _1_Lucene40_0.prx.
- See Also:
ServiceLoader
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
PER_FIELD_FORMAT_KEY
FieldInfo
attribute name used to store the format name for each field.static java.lang.String
PER_FIELD_NAME
Name of thisPostingsFormat
.static java.lang.String
PER_FIELD_SUFFIX_KEY
FieldInfo
attribute name used to store the segment suffix name for each field.-
Fields inherited from class org.apache.lucene.codecs.PostingsFormat
EMPTY
-
-
Constructor Summary
Constructors Constructor Description PerFieldPostingsFormat()
Sole constructor.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description FieldsConsumer
fieldsConsumer(SegmentWriteState state)
Writes a new segmentFieldsProducer
fieldsProducer(SegmentReadState state)
Reads a segment.abstract PostingsFormat
getPostingsFormatForField(java.lang.String field)
Returns the postings format that should be used for writing new segments offield
.-
Methods inherited from class org.apache.lucene.codecs.PostingsFormat
availablePostingsFormats, forName, getName, reloadPostingsFormats, toString
-
-
-
-
Field Detail
-
PER_FIELD_NAME
public static final java.lang.String PER_FIELD_NAME
Name of thisPostingsFormat
.- See Also:
- Constant Field Values
-
PER_FIELD_FORMAT_KEY
public static final java.lang.String PER_FIELD_FORMAT_KEY
FieldInfo
attribute name used to store the format name for each field.
-
PER_FIELD_SUFFIX_KEY
public static final java.lang.String PER_FIELD_SUFFIX_KEY
FieldInfo
attribute name used to store the segment suffix name for each field.
-
-
Method Detail
-
fieldsConsumer
public final FieldsConsumer fieldsConsumer(SegmentWriteState state) throws java.io.IOException
Description copied from class:PostingsFormat
Writes a new segment- Specified by:
fieldsConsumer
in classPostingsFormat
- Throws:
java.io.IOException
-
fieldsProducer
public final FieldsProducer fieldsProducer(SegmentReadState state) throws java.io.IOException
Description copied from class:PostingsFormat
Reads a segment. NOTE: by the time this call returns, it must hold open any files it will need to use; else, those files may be deleted. Additionally, required files may be deleted during the execution of this call before there is a chance to open them. Under these circumstances an IOException should be thrown by the implementation. IOExceptions are expected and will automatically cause a retry of the segment opening logic with the newly revised segments.- Specified by:
fieldsProducer
in classPostingsFormat
- Throws:
java.io.IOException
-
getPostingsFormatForField
public abstract PostingsFormat getPostingsFormatForField(java.lang.String field)
Returns the postings format that should be used for writing new segments offield
.The field to format mapping is written to the index, so this method is only invoked when writing, not when reading.
-
-