Solr managed schemas
Solr has a RESTful API that you use to manage schemas programmatically.
Solr has a RESTful API that you use to manage schemas programmatically. The cores and collections reload automatically after you update the schema.
Solr sample configuration sets use managed schemas instead of the legacy manual schema (
Sitecore supports managed schemas, and has a tool that you use to populate the schema using the Schema API directly to Solr.
To prepare the config sets and the managed schema:
Copy the Solr provided configuration example from the
[SOLR_DIR]/server/solrand rename it to the appropriate index name.
Create a text file called
core.propertiesin the folder you created (
[SOLR_DIR]/server/solr/[CORE_NAME]), and specify the following values:RequestResponseshell
name=[CORE_NAME] config=solrconfig.xml update.autoCreateFields=false dataDir=data
Open the managed schema file in the
confsubfolder of the folder created in step 1.
Set the value in
In the fields section, add the following field configuration for
<field name="_uniqueid" type="string" indexed="true" required="true" stored="true"/>
Save your changes.
Repeat step 1 and step 2 for all content search indexes.Note
Do not do this for the xdb indexes. Use this description instead.
To populate the schema from the Control Panel:
Start Sitecore, and go to the Control Panel.
In the Indexing tab, click Populate Solr Managed Schema:
In the Schema Populate window, select the indexes you want to populate:
Populate schema from admin page
You can populate schemas from the admin page. This is especially useful if you populate schemas from PowerShell scripts.
To do so:
http://YOUR_INSTANCE/sitecore/admin/ PopulateManagedSchema.aspx?indexes=sitecore_master_index|sitecore_core_index|sitecore_web_index. You use the
indexesquery parameter to pass the names of the indexes that you want to populate as a pipe (‘|’) separated list.
Inspect the HTTP status code to verify the result (200 means success).
Populate schema using the Sitecore CLI
To populate schemas using the Sitecore CLI:
sitecore index schema-populatecommand in a terminal.
For more information, see The CLI index command. This command is available from CLI 4.0 or later.
Disable the ability to change the schema programmatically
You can disable the ability to change the schema programmatically by setting the
<schemaFactory> class to
ClassicIndexSchemaFactory in the
solrconfig.xml file. For more information, see the Schema Factory Definition documentation for the Solr version that is compatible with your version of Sitecore XP.
If you disable the ability to change the schema programmatically, then the schema file must be edited manually. The methods to automatically populate the schema, including those described in this topic, will not work.