FactorPad
Faster Learning Tutorials

Solr Field Types : syntax, options and examples

Below is a list of 21 Field Types included with Apache Solr 7.
  1. About - Understand the purpose of Field Types.
  2. Syntax - See how Solr Field Types are coded in the schema.
  3. Options - View the list of 21 Field Types.
  4. Examples - Review examples of usage.
by Paul Alan Davis, CFA, November 16, 2017
Updated: July 16, 2018
Here we focus on the specification in the XML-formatted schema.xml or managed-schema files.

Outline Back Next

~/ home  / tech  / solr  / reference  / solr field types


Solr Field Types

Beginner

The following information is provided for those evaluating Apache Solr for website search or enterprise search applications. Solr uses Lucene libraries for custom search much as Elasticsearch does.

Apache Solr Reference

1. About Solr Field Types

Solr schema refers to a configuration file that instructs Solr how to index documents. Documents may contain structured data like you might find in a database like an online store, or unstructured data as used in full text search applications like search engines.

The Solr schema is formatted in the file called managed-schema when the user elects to make modifications using the Solr Schema API, or schema.xml for more advanced users who modify the schema by hand.

Fields in Solr are custom to the documents themselves and the information being searched for. Each Field is assigned a Field Type which provides rules for how Fields of that type should be processed.

2. Syntax for Solr Fields and Field Types

An example for both Field Types and Fields might look like this (including the XML and schema tags).

<?xml version="1.0" encoding="UTF-8"?> <schema name="default-config" version="1.6"> ... <fieldType name="text_general" class="solr.TextField" positionIncrementGap="100" multiValued="true"/> ... <field name="title" type="text_general"/> ... </schema>

The schema file is typically hundreds of lines long, and above is a snippet first of a simple Field Type that processes Fields that are given the type="text_general" name. In this case, the title Field pulled from the indexed document is assigned this Field Type.

Where you see class="solr.TextField", this is where Solr points to a class of code that processes Fields of that type, in this case text. There are 21 such classes provided by Solr version 7 listed below.

3. Options for the Different fieldType Classes in Apache Solr

Below is a list of 21 Field Type classes provided by Solr 7 that are not soon to be deprecated. The full path to point to the class is org.apache.solr.schema.<fieldType> but this can be abbreviated simply with solr.<fieldType>.

fieldType Description
BinaryField For binary data.
BoolField For true or false data.
CollationField For multiple language processing with Unicode symbols.
CurrencyFieldType For currencies and exchange rate data.
DateRangeField For date range calculations.
DatePointField For date Fields at a point in time.
DoublePointField For 64-bit floating point data.
ExternalFileField For data located in an external file.
EnumFieldType For ordering data using a scheme other than alphabetic or numeric sorting.
FloatPointField For 32-bit floating point data.
ICUCollationField For Unicode Field specifications.
IntPointField For 32-bit signed integers.
LatLonPointSpatialField For geospatial data, this holds latitudes and longitudes.
LongPointField For 64-bit signed integers.
PointType For sorting geospatial data.
PreAnalyzedField For passing tokens that have already been analyzed.
RandomSortField For returning search results in random order.
RPT For geospatial data coordinates. The long form is SpatialRecursivePrefixTreeFieldType.
StrField For short strings encoded with UTF-8 Unicode and are not analyzed or tokenized.
TextField For text that includes multiple words to be broken into tokens.
UUIDField For a Universally Unique Identifier (UUID) Field.

4. Examples of Common Solr Field Types

Example 1 - The BinaryField type

The following is an example of a Field Type definition for binary Fields.

<fieldType name="binary" class="solr.BinaryField"/>
Example 2 - The BoolField type

The following is an example of a Field Type definition for boolean Fields.

<fieldType name="boolean" class="solr.BoolField" sortMissingLast="true"/>
Example 3 - The TextField type

The following is an example of a Field Type definition for text Fields with a one-line analyzer class. It is more common to have multi-line analyzer classes for text Fields.

<fieldType name="text_general" class="solr.TextField"> <analyzer class="solr.StandardAnalyzerFactory"/> </fieldType>
Example 4 - The StrField type

The following is an example of a Field Type definition for string Fields.

<fieldType name="string" class="solr.StrField" sortMissingLast="true" docValues="true"/> </fieldType>

Other Related Solr Content

FactorPad offers Apache Solr Search content in both tutorials and reference.


What's Next?

See what other free learning is available at our YouTube Channel. Subscribe here.

  • To see the outline of Solr reference material, click Outline.
  • To learn about the Solr post tool, click Back.
  • To see our page on Solr Field Type Properties, click Next.

Outline Back Next

~/ home  / tech  / solr  / reference  / solr field types



 
 
Keywords:
solr reference
apache solr
solr search
custom search
enterprise search
apache lucene
lucene reference
solr examples
solr field types
solr syntax
solr help
solr version
elasticsearch
solr settings
solr configuration
solr man page