Your schema.xml is the structure of the index: which fields exist, what kind of data each one holds, and how it is analyzed when you index and when you search.
01 · Where to edit it
In your Opensolr account, open the index management area and click the Edit schema.xml tab:
https://opensolr.com/admin/solr_manager/tools/YOUR_INDEX_NAME
02 · Defining a field
Fields go inside the <fields> section:
<field name="full_name" type="text_general" indexed="true" stored="true" />
| Attribute | What it means |
|---|---|
name | The field name, used when indexing and when querying. |
type | The field type, which decides how the value is analyzed and stored. |
indexed="true" | The field is searchable. Set it to false if you only ever retrieve the value. |
stored="true" | The original value is kept and can be returned in results. |
multiValued="true" | The field can hold several values, for example tags. |
required="true" | A document without it cannot be indexed. Normally only the id field. |
03 · The field types you will actually use
| Type | Behaviour | Use it for |
|---|---|---|
text_general | Tokenized text with standard analysis. | Full-text fields: titles, descriptions, body copy. |
string | Exact, untokenized value. | Ids, categories, facets, filters. |
int / pint | Integer. | Counts and quantities. |
tint | Trie-based integer, a legacy type. | Range queries on integers. |
tfloat / tdouble | Trie-based decimals. | Prices, measurements, decimal ranges. |
boolean | True or false. | Flags and toggles. |
date / pdate | ISO 8601 date and time. | Timestamps and date filtering. |
04 · Range queries
A numeric trie field supports ranges:
<field name="age" type="tint" indexed="true" stored="true" />
which lets you ask for everything above thirteen:
https://YOUR_SOLR_HOST/solr/YOUR_INDEX/select?q=age:[13 TO *]
The same applies to tfloat and tdouble, which is how a price filter is built.
05 · Dynamic fields
Your schema also carries wildcard definitions that match any field name fitting the pattern:
<dynamicField name="*_s" type="string" indexed="true" stored="true" /> <dynamicField name="*_i" type="int" indexed="true" stored="true" /> <dynamicField name="*_t" type="text_general" indexed="true" stored="true" />
A field called color_s is then a string without you declaring it. Keep them or remove them: they do not affect the fields you define explicitly.
06 · Further reading
Every attribute a field definition accepts.
Field types included with Solr
The complete list of types and what each one does.
Analyzers, tokenizers and filters
How a text field is broken into terms, which is what decides what matches.