FactorPad
Build a Better Process

Solr Field Type Properties : Syntax, Options and Examples

Below is a list of 7 general properties that apply to any Field Type in Apaceh Solr
  1. About - Understand the purpose of general Field Type properties.
  2. Syntax - See how Solr Field Type properties are coded in the schema.
  3. Options - View the list of 7 general Field Type properties.
  4. Examples - Review examples of usage.
face pic by Paul Alan Davis, CFA
Updated: February 25, 2021
Here we focus on the specifications in the XML-formatted schema.xml or managed-schema files.

Outline Back Tip Next

/ factorpad.com / tech / solr / reference / solr-field-type-properties.html


An ad-free and cookie-free website.


Solr Field Type Properties

Beginner

The following data is intended for developers evaluating Apache Solr for enterprise search or website search applications. Solr, much like Elasticsearch, uses Lucene libraries for custom search.

Apache Solr Reference

1. About Solr Field Type Properties

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 related 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 name="text_general" and class="solr.TextField" in the fieldType tag, these are examples of Field Type properties. In fact, these are the two required properties for any Field Type.

The table below provides a list and description of all 7 general properties that can be included in the fieldType tag.

3. Options for the Different fieldType Properties in Apache Solr

Below is a list of 7 Field Type properties provided by Solr.

fieldType Property Description
name (required) Each Field points to a Field Type using the type="name" attribute. The Field Type is then used to process text in that Field according to the rules of the Field Type during both indexing and querying.
class(required) The class points to the code that processes data for that Field Type. It is located at org.apache.solr.schema.<class> but can be abbreviated with solr.<class>.
positionIncrementGap If a document can have mutiple values for a Field Type then it is considered multiValued. This property sets the distance between multiple values and is helpful for fine-tuning phrase (multiple word) settings so searches don't provide false phrase matches.
autoGeneratePhraseQueries For text fields, true will automatically create phrases for adjacent terms. For example, creating a token for "new york" when those two words are adjacent instead of only "new" and "york". With false all phrases must be enclosed in double quotes during indexing or searching.
enableGraphQueries The default of true when filters are graph-aware, like the Synonym Graph Filter. Use false for filters that match documents when tokens are missing, like the Shingle Filter.
docValuesFormat An advanced setting when a custom docValues format is established in the solrconfig.xml.
postingsFormat And advanced setting for custom postingFormat as set up in the solrconfig.xml.

4. Examples of Common Solr Field Type Properties

Example 1 - The name and class properties

The following is an example of name and class set up for the binary Field Type.

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

The following is an example of a positionIncrementGap property for a text field.

<fieldType name="text_general" class="solr.TextField" positionIncrementGap="100"> ... </fieldType>
Example 3 - The autoGeneratePhraseQueries Property

The following is an example of an autoGeneratePhraseQueries property for a text field.

<fieldType name="text_general" class="solr.TextField" autoGeneratePhraseQueries="true"> ... </fieldType>

Other Related Solr Content

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


What's Next?

See what other developers like yourself are learning at our YouTube Channel. Follow @factorpad on Twitter for updates on new content.

Outline Back Tip Next

/ factorpad.com / tech / solr / reference / solr-field-type-properties.html


solr field type properties
apache solr
solr reference
enterprise search
apache lucene
lucene field type properties
apache solr search
solr examples
solr field class properties
solr syntax
solr help
solr configuration
custom search
solr man page

A newly-updated free resource. Connect and refer a friend today.