You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by "Steve Rowe (Confluence)" <co...@apache.org> on 2013/07/24 19:40:00 UTC
[CONF] Apache Solr Reference Guide > Managed Schema Definition in
SolrConfig
Space: Apache Solr Reference Guide (https://cwiki.apache.org/confluence/display/solr)
Page: Managed Schema Definition in SolrConfig (https://cwiki.apache.org/confluence/display/solr/Managed+Schema+Definition+in+SolrConfig)
Change Comment:
---------------------------------------------------------------------
4.4 update
Edited by Steve Rowe:
---------------------------------------------------------------------
The [Schema API] enables [schema|Documents, Fields, and Schema Design] modifications through a REST interface.
There are challenges with allowing programmatic access to a configuration file that is also open to manual edits: system-generated and manual edits may overlap and the system-generated edits may remove comments or other customizations that are critical for the organization to understand why fields, field types, etc., are defined the way they are. You may want to version the file with source control, or limit manual edits altogether.
{{solrconfig.xml}} allows {{schema.xml}} to be defined as a "managed index schema". This allows locking the schema against unauthorized edits. It also locks the schema so only the Schema API can modify it.
>From the example {{solrconfig.xml}}:
{code:borderStyle=solid|borderColor=#666666}
<!-- To enable dynamic schema REST APIs, use the following for <schemaFactory>:
<schemaFactory class="ManagedIndexSchemaFactory">
<bool name="mutable">true</bool>
<str name="managedSchemaResourceName">managed-schema</str>
</schemaFactory>
When ManagedIndexSchemaFactory is specified, Solr will load the schema from
the resource named in 'managedSchemaResourceName', rather than from schema.xml.
Note that the managed schema resource CANNOT be named schema.xml. If the managed
schema does not exist, Solr will create it after reading schema.xml, then rename
'schema.xml' to 'schema.xml.bak'.
Do NOT hand edit the managed schema - external modifications will be ignored and
overwritten as a result of schema modification REST API calls.
When ManagedIndexSchemaFactory is specified with mutable = true, schema
modification REST API calls will be allowed; otherwise, error responses will be
sent back for these requests.
-->
<schemaFactory class="ClassicIndexSchemaFactory"/>
{code}
In the example above, {{solrconfig.xml}} is actually configured to use the {{ClassicIndexSchemaFactory}}, which treats the {{schema.xml}} file the same as it always has, which is that it can be edited manually. This setting disallows [Schema
API] methods that modify the schema.
In the commented out sample, however, you can see configuration for the managed schema. In order for schema modifications to be possible via the [Schema API], the {{ManagedIndexSchemaFactory}} will need to be used. The parameter {{mutable}} must also be set to *true*. The {{managedSchemaResourceName}}, which defaults to "managed-schema", may also be defined, and can be anything other than "schema.xml". Once Solr is restarted, the existing {{schema.xml}} file is renamed to {{schema.xml.bak}} and the contents are written to a file with the name defined as the {{managedSchemaResourceName}}. If you look at the resulting file, you'll see this at the top of the page:
{code:borderStyle=solid|borderColor=#666666}
<!-- Solr managed schema - automatically generated - DO NOT EDIT -->
{code}
Note that the [Schemaless Mode] example at {{example/example-schemaless/}} uses the {{ManagedIndexSchemaFactory}} to allow automatic schema field additions based on document updates'/additions' field values.
{scrollbar}
Stop watching space: https://cwiki.apache.org/confluence/users/removespacenotification.action?spaceKey=solr
Change email notification preferences: https://cwiki.apache.org/confluence/users/editmyemailsettings.action