org.apache.solr.schema
Class SchemaField

java.lang.Object
  extended by org.apache.solr.schema.FieldProperties
      extended by org.apache.solr.schema.SchemaField

public final class SchemaField
extends FieldProperties

Encapsulates all information about a Field in a Solr Schema


Field Summary
 
Fields inherited from class org.apache.solr.schema.FieldProperties
BINARY, DOC_VALUES, INDEXED, MULTIVALUED, OMIT_NORMS, OMIT_POSITIONS, OMIT_TF_POSITIONS, REQUIRED, SORT_MISSING_FIRST, SORT_MISSING_LAST, STORE_OFFSETS, STORE_TERMOFFSETS, STORE_TERMPOSITIONS, STORE_TERMVECTORS, STORED, TOKENIZED
 
Constructor Summary
SchemaField(SchemaField prototype, String name)
          Create a new SchemaField from an existing one by using all of the properties of the prototype except the field name.
SchemaField(String name, FieldType type)
          Create a new SchemaField with the given name and type, using all the default properties from the type.
SchemaField(String name, FieldType type, int properties, String defaultValue)
          Create a new SchemaField with the given name and type, and with the specified properties.
 
Method Summary
 void checkFieldCacheSource(QParser parser)
          Sanity checks that the properties of this field type are plausible for a field that may be used to get a FieldCacheSource, throwing an appropriate exception (including the field name) if it is not.
 void checkSortability()
          Sanity checks that the properties of this field type are plausible for a field that may be used in sorting, throwing an appropriate exception (including the field name) if it is not.
 IndexableField createField(Object val, float boost)
           
 List<IndexableField> createFields(Object val, float boost)
           
 boolean equals(Object obj)
           
 String getDefaultValue()
           
 String getName()
           
 SimpleOrderedMap<Object> getNamedPropertyValues(boolean showDefaults)
          Get a map of property name -> value for this field.
 int getProperties()
           
 SortField getSortField(boolean top)
          Delegates to the FieldType for this field
 FieldType getType()
           
 boolean hasDocValues()
           
 int hashCode()
           
 boolean indexed()
           
 boolean isPolyField()
          If true, then use createFields(Object, float), else use createField(java.lang.Object, float) to save an extra allocation
 boolean isRequired()
           
 boolean multiValued()
           
 boolean omitNorms()
           
 boolean omitPositions()
           
 boolean omitTermFreqAndPositions()
           
 boolean omitTf()
          Deprecated. Use omitTermFreqAndPositions()
 boolean sortMissingFirst()
           
 boolean sortMissingLast()
           
 boolean stored()
           
 boolean storeOffsetsWithPositions()
           
 boolean storeTermOffsets()
           
 boolean storeTermPositions()
           
 boolean storeTermVector()
           
 String toString()
           
 void write(TextResponseWriter writer, String name, IndexableField val)
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SchemaField

public SchemaField(String name,
                   FieldType type)
Create a new SchemaField with the given name and type, using all the default properties from the type.


SchemaField

public SchemaField(SchemaField prototype,
                   String name)
Create a new SchemaField from an existing one by using all of the properties of the prototype except the field name.


SchemaField

public SchemaField(String name,
                   FieldType type,
                   int properties,
                   String defaultValue)
Create a new SchemaField with the given name and type, and with the specified properties. Properties are *not* inherited from the type in this case, so users of this constructor should derive the properties from type.getSolrProperties() using all the default properties from the type.

Method Detail

getName

public String getName()

getType

public FieldType getType()

getProperties

public int getProperties()

indexed

public boolean indexed()

stored

public boolean stored()

hasDocValues

public boolean hasDocValues()

storeTermVector

public boolean storeTermVector()

storeTermPositions

public boolean storeTermPositions()

storeTermOffsets

public boolean storeTermOffsets()

omitNorms

public boolean omitNorms()

omitTf

@Deprecated
public boolean omitTf()
Deprecated. Use omitTermFreqAndPositions()


omitTermFreqAndPositions

public boolean omitTermFreqAndPositions()

omitPositions

public boolean omitPositions()

storeOffsetsWithPositions

public boolean storeOffsetsWithPositions()

multiValued

public boolean multiValued()

sortMissingFirst

public boolean sortMissingFirst()

sortMissingLast

public boolean sortMissingLast()

isRequired

public boolean isRequired()

createField

public IndexableField createField(Object val,
                                  float boost)

createFields

public List<IndexableField> createFields(Object val,
                                         float boost)

isPolyField

public boolean isPolyField()
If true, then use createFields(Object, float), else use createField(java.lang.Object, float) to save an extra allocation

Returns:
true if this field is a poly field

toString

public String toString()
Overrides:
toString in class Object

write

public void write(TextResponseWriter writer,
                  String name,
                  IndexableField val)
           throws IOException
Throws:
IOException

getSortField

public SortField getSortField(boolean top)
Delegates to the FieldType for this field

See Also:
FieldType.getSortField(org.apache.solr.schema.SchemaField, boolean)

checkSortability

public void checkSortability()
                      throws SolrException
Sanity checks that the properties of this field type are plausible for a field that may be used in sorting, throwing an appropriate exception (including the field name) if it is not. FieldType subclasses can choose to call this method in their getSortField implementation

Throws:
SolrException
See Also:
FieldType.getSortField(org.apache.solr.schema.SchemaField, boolean)

checkFieldCacheSource

public void checkFieldCacheSource(QParser parser)
                           throws SolrException
Sanity checks that the properties of this field type are plausible for a field that may be used to get a FieldCacheSource, throwing an appropriate exception (including the field name) if it is not. FieldType subclasses can choose to call this method in their getValueSource implementation

Throws:
SolrException
See Also:
FieldType.getValueSource(org.apache.solr.schema.SchemaField, org.apache.solr.search.QParser)

getDefaultValue

public String getDefaultValue()

hashCode

public int hashCode()
Overrides:
hashCode in class Object

equals

public boolean equals(Object obj)
Overrides:
equals in class Object

getNamedPropertyValues

public SimpleOrderedMap<Object> getNamedPropertyValues(boolean showDefaults)
Get a map of property name -> value for this field. If showDefaults is true, include default properties (those inherited from the declared property type and not overridden in the field declaration).



Copyright © 2000-2014 Apache Software Foundation. All Rights Reserved.