Configuration File managed-schema in the Solr Config Set
The managed-schema file needs to be specified when you add documents to an index. The managed-schema file consists of three parts: Field, FieldType, and uniqueKey.
The current Solr kernel version is 8.11.2. In this version, the managed-schema configuration file is used to replace schema.xml in earlier versions. You can add and modify fields by modifying this file. If you keep using the original config set, solrconfig.xml and schema.xml must be the mapping configuration files of earlier versions, and you can add and modify fields by modifying the schema.xml file. In the solrconfig.xml file, <schemaFactory class="ClassicIndexSchemaFactory"/> indicates that schema.xml is used, and <schemaFactory class="ManagedIndexSchemaFactory"/> indicates that managed-schema is used. The latest solrconfig.xml file uses <schemaFactory class="ManagedIndexSchemaFactory"/> by default.
fields
The managed-schema file is similar to the data table configuration file. It defines the data type of the data to be added to the index, including the type, fields, and other default settings. A field is the basic unit of index data. In managed-schema, in addition to fields of the basic numeric type, some special fields are supported, such as copyField and dynamicField.
- field
<field name="id" type="string" indexed="true" stored="true" required="true"/> <field name="name" type="text" indexed="true" stored="true" multiValued="true"/>
Specific fields (similar to database fields) defined on the fields node are as follows:
- name: field name
- type: field type
- indexed: whether the field is used for creating a collection (related to search and sorting)
- stored: whether the field is stored
- multiValued: whether a field includes multiple values
- copyField
Solr has a field replication mechanism that allows fields of different types to be integrated into one field. Field replication involves two concepts: source and destination. One is a field to be copied, and the other is a field to which the field is copied.
<copyFieldsource="name"dest="text"/>
When adding an index, copy all data in a field (for example, name) to the text field.
During the search, Solr searches the content of the text field by default. When data of the name field and other fields is copied to the text field, the content of these fields can be searched together, improving search efficiency.
- dynamicField
Dynamic fields allow Solr to index the fields that are not clearly defined in the managed-schema file. Dynamic fields improve the flexibility and universality of the system.
<dynamicFieldname="*_i"type="int"indexed="true"stored="true"/>
For example, the *_i dynamic field is defined in the managed-schema file, but the cost_i and price_i fields are not defined. During index creation, you can create indexes by cost_i and price_i. You can create indexes for all fields starting with a letter or digit and ending with _i using the *_i dynamic field.
Key Fields
<uniqueKey>id</uniqueKey>
This field indicates the unique ID of the document and must be set (unless this field is marked by required="false"). If this field is not set, errors will be reported when indexes are created in Solr. The default value is id.
<defaultSearchField>text</defaultSearchField>
This field indicates the default search field. If no field is specified in search parameters, text will be regarded as the default search domain.
<solrQueryParser defaultOperator="OR"/>
This field indicates the search logic between parameters. The default value is OR. If you need to search two parameters at the same time, change the value to AND.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot