|
Size: 6970
Comment:
|
← Revision 9 as of 2013-04-25 23:16:39 ⇥
Size: 7136
Comment:
|
| Deletions are marked like this. | Additions are marked like this. |
| Line 55: | Line 55: |
| <!> NOTE <!> Converting a SolrCloud configset's schema to managed, and adding fields to the schema, will affect all other collections that use the same configset. |
Schema REST API
Reading schema information
Solr 4.2
The Solr schema REST API provides information about the schema used by Solr cores and collections.
To query a schema for a particular core or collection, add the core or collection name after the context path (usually '/solr/'). E.g. to get all field declarations for collection1: http://localhost:8983/solr/collection1/schema/fields
Supported requests (URLs are for single/default core):
Schema component |
HTTP method |
Example URL |
Supported query params |
Default params |
All requests |
wt, indent |
?wt=json&indent=on |
||
All (entire schema) ( |
GET |
wt=json or wt=xml or wt=schema.xml |
|
|
Fields |
GET |
fl, includeDynamic, showDefaults |
&showDefaults=false |
|
GET |
includeDynamic, showDefaults |
&showDefaults=false |
||
Dynamic Fields |
GET |
fl, showDefaults |
&showDefaults=false |
|
GET |
showDefaults |
&showDefaults=false |
||
Field Types |
GET |
showDefaults |
&showDefaults=false |
|
GET |
showDefaults |
&showDefaults=false |
||
Copy Fields |
GET |
source.fl, dest.fl |
|
|
Name ( |
GET |
|
|
|
Version ( |
GET |
|
|
|
Unique Key ( |
GET |
|
|
|
Global Similarity ( |
GET |
|
|
|
Default Query Operator ( |
GET |
http://localhost:8983/solr/schema/solrqueryparser/defaultoperator |
|
|
Adding fields to a schema
Solr 4.4
Fields may be added to a schema if the field name(s) are not already in the schema, and if the field name(s) don't match any dynamicFields.
In order to enable schema modifications via the Schema REST API, the schema implementation must be declared as managed by Solr, that is, not to be manually edited. See SOLR-4658 for more information.
Further, the schema must be configured as mutable in order to make modifications to it.
Both of these schema features (managed and mutable) are configured via the <schemaFactory/> element in solrconfig.xml.
Here is an example declaring the schema to be managed and mutable, to be persisted in a resource named managed-schema, either as a file in the core's conf/ directory, or as a ZooKeeper znode in the configset used by the collection:
<schemaFactory class="ManagedIndexSchemaFactory"> <bool name="mutable">true</bool> <str name="managedSchemaResourceName">managed-schema</str> </schemaFactory>
The first time you load a core with the above declaration in the corresponding solrconfig.xml, it will convert the existing schema to managed format, persist the result to the resource you name in the configuration, and rename the original schema file by appending .bak to its name, e.g. schema.xml will be renamed to schema.xml.bak.
NOTE
Converting a SolrCloud configset's schema to managed, and adding fields to the schema, will affect all other collections that use the same configset.
Supported requests - note that at present, only JSON is supported for the body of these requests:
Operation |
HTTP method |
Example URL |
Example Body |
Supported query params |
Default params |
All requests |
wt, indent |
?wt=json&indent=on |
|||
Add Multiple Fields |
POST |
[{"name":"newfield1","type":"text","stored":"false"}, |
|
|
|
Add a Single Field |
PUT |
{"type":"text","stored":"false"} |
|
|
|