Package org.apache.lucene.index
Class FieldInfo
- java.lang.Object
-
- org.apache.lucene.index.FieldInfo
-
public final class FieldInfo extends java.lang.Object
Access to the Field Info file that describes document fields and whether or not they are indexed. Each segment has a separate Field Info file. Objects of this class are thread-safe for multiple readers, but only one thread can be adding documents at a time, with no other reader or writer threads accessing this object.
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.Map<java.lang.String,java.lang.String>
attributes
private DocValuesType
docValuesType
private long
dvGen
private IndexOptions
indexOptions
java.lang.String
name
Field's nameint
number
Internal field numberprivate boolean
omitNorms
private int
pointDimensionCount
If both of these are positive it means this field indexed points (seePointsFormat
).private int
pointIndexDimensionCount
private int
pointNumBytes
private boolean
softDeletesField
private boolean
storePayloads
private boolean
storeTermVector
private int
vectorDimension
private VectorSimilarityFunction
vectorSimilarityFunction
-
Constructor Summary
Constructors Constructor Description FieldInfo(java.lang.String name, int number, boolean storeTermVector, boolean omitNorms, boolean storePayloads, IndexOptions indexOptions, DocValuesType docValues, long dvGen, java.util.Map<java.lang.String,java.lang.String> attributes, int pointDimensionCount, int pointIndexDimensionCount, int pointNumBytes, int vectorDimension, VectorSimilarityFunction vectorSimilarityFunction, boolean softDeletesField)
Sole constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.Map<java.lang.String,java.lang.String>
attributes()
Returns internal codec attributes map.void
checkConsistency()
Check correctness of the FieldInfo optionsjava.lang.String
getAttribute(java.lang.String key)
Get a codec attribute value, or null if it does not existlong
getDocValuesGen()
Returns the docValues generation of this field, or -1 if no docValues updates exist for it.DocValuesType
getDocValuesType()
ReturnsDocValuesType
of the docValues; this isDocValuesType.NONE
if the field has no docvalues.int
getFieldNumber()
Returns the field numberIndexOptions
getIndexOptions()
Returns IndexOptions for the field, or IndexOptions.NONE if the field is not indexedjava.lang.String
getName()
Returns name of this fieldint
getPointDimensionCount()
Return point data dimension countint
getPointIndexDimensionCount()
Return point data dimension countint
getPointNumBytes()
Return number of bytes per dimensionint
getVectorDimension()
Returns the number of dimensions of the vector valueVectorSimilarityFunction
getVectorSimilarityFunction()
ReturnsVectorSimilarityFunction
for the fieldboolean
hasNorms()
Returns true if this field actually has any norms.boolean
hasPayloads()
Returns true if any payloads exist for this field.boolean
hasVectors()
Returns true if any term vectors exist for this field.boolean
hasVectorValues()
Returns whether any (numeric) vector values exist for this fieldboolean
isSoftDeletesField()
Returns true if this field is configured and used as the soft-deletes field.boolean
omitsNorms()
Returns true if norms are explicitly omitted for this fieldjava.lang.String
putAttribute(java.lang.String key, java.lang.String value)
Puts a codec attribute value.(package private) void
setDocValuesGen(long dvGen)
Sets the docValues generation of this field.void
setDocValuesType(DocValuesType type)
Record that this field is indexed with docvalues, with the specified typevoid
setOmitsNorms()
Omit norms for this field.void
setPointDimensions(int dimensionCount, int indexDimensionCount, int numBytes)
Record that this field is indexed with points, with the specified number of dimensions and bytes per dimension.(package private) void
setStorePayloads()
(package private) void
setStoreTermVectors()
(package private) static void
verifySameDocValuesType(java.lang.String fieldName, DocValuesType docValuesType1, DocValuesType docValuesType2, boolean strictlyConsistent)
Verify that the provided docValues type are the same(package private) static void
verifySameIndexOptions(java.lang.String fieldName, IndexOptions indexOptions1, IndexOptions indexOptions2, boolean strictlyConsistent)
Verify that the provided index options are the same(package private) static void
verifySameOmitNorms(java.lang.String fieldName, boolean omitNorms1, boolean omitNorms2, boolean strictlyConsistent)
Verify that the provided omitNorms are the same(package private) static void
verifySamePointsOptions(java.lang.String fieldName, int pointDimensionCount1, int indexDimensionCount1, int numBytes1, int pointDimensionCount2, int indexDimensionCount2, int numBytes2, boolean strictlyConsistent)
Verify that the provided points indexing options are the same(package private) void
verifySameSchema(FieldInfo o, boolean strictlyConsistent)
Verify that the provided FieldInfo has the same schema as this FieldInfo(package private) static void
verifySameStoreTermVectors(java.lang.String fieldName, boolean storeTermVector1, boolean storeTermVector2, boolean strictlyConsistent)
Verify that the provided store term vectors options are the same(package private) static void
verifySameVectorOptions(java.lang.String fieldName, int vd1, VectorSimilarityFunction vsf1, int vd2, VectorSimilarityFunction vsf2)
Verify that the provided vector indexing options are the same
-
-
-
Field Detail
-
name
public final java.lang.String name
Field's name
-
number
public final int number
Internal field number
-
docValuesType
private DocValuesType docValuesType
-
storeTermVector
private boolean storeTermVector
-
omitNorms
private boolean omitNorms
-
indexOptions
private final IndexOptions indexOptions
-
storePayloads
private boolean storePayloads
-
attributes
private final java.util.Map<java.lang.String,java.lang.String> attributes
-
dvGen
private long dvGen
-
pointDimensionCount
private int pointDimensionCount
If both of these are positive it means this field indexed points (seePointsFormat
).
-
pointIndexDimensionCount
private int pointIndexDimensionCount
-
pointNumBytes
private int pointNumBytes
-
vectorDimension
private final int vectorDimension
-
vectorSimilarityFunction
private final VectorSimilarityFunction vectorSimilarityFunction
-
softDeletesField
private final boolean softDeletesField
-
-
Constructor Detail
-
FieldInfo
public FieldInfo(java.lang.String name, int number, boolean storeTermVector, boolean omitNorms, boolean storePayloads, IndexOptions indexOptions, DocValuesType docValues, long dvGen, java.util.Map<java.lang.String,java.lang.String> attributes, int pointDimensionCount, int pointIndexDimensionCount, int pointNumBytes, int vectorDimension, VectorSimilarityFunction vectorSimilarityFunction, boolean softDeletesField)
Sole constructor.
-
-
Method Detail
-
checkConsistency
public void checkConsistency()
Check correctness of the FieldInfo options- Throws:
java.lang.IllegalArgumentException
- if some options are incorrect
-
verifySameSchema
void verifySameSchema(FieldInfo o, boolean strictlyConsistent)
Verify that the provided FieldInfo has the same schema as this FieldInfo- Parameters:
o
- – other FieldInfo whose schema is verified against this FieldInfo's schema- Throws:
java.lang.IllegalArgumentException
- if the field schemas are not the same
-
verifySameIndexOptions
static void verifySameIndexOptions(java.lang.String fieldName, IndexOptions indexOptions1, IndexOptions indexOptions2, boolean strictlyConsistent)
Verify that the provided index options are the same- Throws:
java.lang.IllegalArgumentException
- if they are not the same
-
verifySameDocValuesType
static void verifySameDocValuesType(java.lang.String fieldName, DocValuesType docValuesType1, DocValuesType docValuesType2, boolean strictlyConsistent)
Verify that the provided docValues type are the same- Throws:
java.lang.IllegalArgumentException
- if they are not the same
-
verifySameStoreTermVectors
static void verifySameStoreTermVectors(java.lang.String fieldName, boolean storeTermVector1, boolean storeTermVector2, boolean strictlyConsistent)
Verify that the provided store term vectors options are the same- Throws:
java.lang.IllegalArgumentException
- if they are not the same
-
verifySameOmitNorms
static void verifySameOmitNorms(java.lang.String fieldName, boolean omitNorms1, boolean omitNorms2, boolean strictlyConsistent)
Verify that the provided omitNorms are the same- Throws:
java.lang.IllegalArgumentException
- if they are not the same
-
verifySamePointsOptions
static void verifySamePointsOptions(java.lang.String fieldName, int pointDimensionCount1, int indexDimensionCount1, int numBytes1, int pointDimensionCount2, int indexDimensionCount2, int numBytes2, boolean strictlyConsistent)
Verify that the provided points indexing options are the same- Throws:
java.lang.IllegalArgumentException
- if they are not the same
-
verifySameVectorOptions
static void verifySameVectorOptions(java.lang.String fieldName, int vd1, VectorSimilarityFunction vsf1, int vd2, VectorSimilarityFunction vsf2)
Verify that the provided vector indexing options are the same- Throws:
java.lang.IllegalArgumentException
- if they are not the same
-
setPointDimensions
public void setPointDimensions(int dimensionCount, int indexDimensionCount, int numBytes)
Record that this field is indexed with points, with the specified number of dimensions and bytes per dimension.
-
getPointDimensionCount
public int getPointDimensionCount()
Return point data dimension count
-
getPointIndexDimensionCount
public int getPointIndexDimensionCount()
Return point data dimension count
-
getPointNumBytes
public int getPointNumBytes()
Return number of bytes per dimension
-
getVectorDimension
public int getVectorDimension()
Returns the number of dimensions of the vector value
-
getVectorSimilarityFunction
public VectorSimilarityFunction getVectorSimilarityFunction()
ReturnsVectorSimilarityFunction
for the field
-
setDocValuesType
public void setDocValuesType(DocValuesType type)
Record that this field is indexed with docvalues, with the specified type
-
getIndexOptions
public IndexOptions getIndexOptions()
Returns IndexOptions for the field, or IndexOptions.NONE if the field is not indexed
-
getName
public java.lang.String getName()
Returns name of this field- Returns:
- name
-
getFieldNumber
public int getFieldNumber()
Returns the field number- Returns:
- field number
-
getDocValuesType
public DocValuesType getDocValuesType()
ReturnsDocValuesType
of the docValues; this isDocValuesType.NONE
if the field has no docvalues.
-
setDocValuesGen
void setDocValuesGen(long dvGen)
Sets the docValues generation of this field.
-
getDocValuesGen
public long getDocValuesGen()
Returns the docValues generation of this field, or -1 if no docValues updates exist for it.
-
setStoreTermVectors
void setStoreTermVectors()
-
setStorePayloads
void setStorePayloads()
-
omitsNorms
public boolean omitsNorms()
Returns true if norms are explicitly omitted for this field
-
setOmitsNorms
public void setOmitsNorms()
Omit norms for this field.
-
hasNorms
public boolean hasNorms()
Returns true if this field actually has any norms.
-
hasPayloads
public boolean hasPayloads()
Returns true if any payloads exist for this field.
-
hasVectors
public boolean hasVectors()
Returns true if any term vectors exist for this field.
-
hasVectorValues
public boolean hasVectorValues()
Returns whether any (numeric) vector values exist for this field
-
getAttribute
public java.lang.String getAttribute(java.lang.String key)
Get a codec attribute value, or null if it does not exist
-
putAttribute
public java.lang.String putAttribute(java.lang.String key, java.lang.String value)
Puts a codec attribute value.This is a key-value mapping for the field that the codec can use to store additional metadata, and will be available to the codec when reading the segment via
getAttribute(String)
If a value already exists for the key in the field, it will be replaced with the new value. If the value of the attributes for a same field is changed between the documents, the behaviour after merge is undefined.
-
attributes
public java.util.Map<java.lang.String,java.lang.String> attributes()
Returns internal codec attributes map.
-
isSoftDeletesField
public boolean isSoftDeletesField()
Returns true if this field is configured and used as the soft-deletes field. SeeLiveIndexWriterConfig.softDeletesField
-
-