Fields
Fields are defined in the fields element of a schema. Once you have the field types set up, defining the fields themselves is simple.
Example Field Definition
The following example defines a field named price
with a type named float
and a default value of 0.0
; the indexed
and stored
properties are explicitly set to true
, while any other properties specified on the float
field type are inherited.
<field name="price" type="float" default="0.0" indexed="true" stored="true"/>
Field Properties
Field definitions can have the following properties:
name
-
Required
Default: none
The name of the field. Field names should consist of alphanumeric or underscore characters only and not start with a digit. This is not currently strictly enforced, but other field names will not have first class support from all components and back compatibility is not guaranteed. Names with both leading and trailing underscores (e.g.,
_version_
) are reserved. type
-
Required
Default: none
The name of the
fieldType
for this field. This will be found in thename
attribute on thefieldType
definition. Every field must have atype
. default
-
Optional
Default: none
A default value that will be added automatically to any document that does not have a value in this field when it is indexed. If this property is not specified, there is no default.
Optional Field Type Override Properties
Fields can have many of the same properties as field types.
Properties from the table below which are specified on an individual field will override any explicit value for that property specified on the fieldType
of the field, or any implicit default property value provided by the underlying fieldType
implementation.
The table below is reproduced from Field Type Definitions and Properties, which has more details:
Property | Description | Implicit Default |
---|---|---|
|
If |
|
|
If |
|
|
If |
|
|
Control the placement of documents when a sort field is not present. |
|
|
If |
|
|
If |
|
|
If |
* |
|
If |
* |
|
Similar to |
* |
|
These options instruct Solr to maintain full term vectors for each document, optionally including position, offset, and payload information for each term occurrence in those vectors. These can be used to accelerate highlighting and other ancillary functionality, but impose a substantial cost in terms of index size. They are not necessary for typical uses of Solr. |
|
|
Instructs Solr to reject any attempts to add a document which does not have a value for this field. This property defaults to false. |
|
|
If the field has DocValues enabled, setting this to true would allow the field to be returned as if it were a stored field (even if it has |
|
|
Large fields are always lazy loaded and will only take up space in the document cache if the actual value is < 512KB. This option requires |
|