You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by Apache Wiki <wi...@apache.org> on 2015/11/19 01:30:20 UTC

[Solr Wiki] Update of "SchemaRESTAPI" by SteveRowe

Dear Wiki user,

You have subscribed to a wiki page or wiki category on "Solr Wiki" for change notification.

The "SchemaRESTAPI" page has been changed by SteveRowe:
https://wiki.apache.org/solr/SchemaRESTAPI?action=diff&rev1=15&rev2=16

Comment:
convert to stub pointing to the ref guide page and encouraging community edits about how to use this feature

- = Schema REST API =
+ /!\ This page exists for the Solr Community to share Tips, Tricks, and Advice about the [[https://cwiki.apache.org/confluence/display/solr/Schema+API|Schema API]].
  
- <<TableOfContents(3)>>
+ Reference material previously located on this page has been migrated to the [[https://cwiki.apache.org/confluence/display/solr/Schema+API|Official Solr Ref Guide]].
  
- == Reading schema information ==
+ If you need help, please consult the ref guide for the version of Solr you are using for the specific details about using the [[https://cwiki.apache.org/confluence/display/solr/Schema+API|Schema API]].
  
- <!> Solr 4.2
+ If you'd like to share information about how you use this feature, please [[https://wiki.apache.org/solr/FrontPage#How_to_edit_this_Wiki|add it to this page]].
  
- 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'''                        ||
- ||||||<bgcolor="#F6F6FF">                             '''All requests'''                                                                         ||<bgcolor="#F6F6FF"> '''wt, indent''' ||<bgcolor="#F6F6FF"> '''?wt=json&indent=on''' ||
- ||<(> All (entire schema)     ( <!> Solr 4.3) || GET                    || [[http://localhost:8983/solr/schema]]                                 || wt=json or wt=xml or wt=schema.xml  ||                                             ||
- ||<(|2> Fields                                || GET                    || [[http://localhost:8983/solr/schema/fields]]                          || fl, includeDynamic, showDefaults    || &showDefaults=false&includeDynamic=false    ||
- ||                                               GET                    || [[http://localhost:8983/solr/schema/fields/]]''name''                 || includeDynamic, showDefaults        || &showDefaults=false&includeDynamic=false    ||
- ||<(|2> Dynamic Fields                        || GET                    || [[http://localhost:8983/solr/schema/dynamicfields]]                   || fl, showDefaults                    || &showDefaults=false                         ||
- ||                                               GET                    || [[http://localhost:8983/solr/schema/dynamicfields/]]''name''          || showDefaults                        || &showDefaults=false                         ||
- ||<(|2> Field Types                           || GET                    || [[http://localhost:8983/solr/schema/fieldtypes]]                      || showDefaults                        || &showDefaults=false                         ||
- ||                                               GET                    || [[http://localhost:8983/solr/schema/fieldtypes/]]''name''             || showDefaults                        || &showDefaults=false                         ||
- ||<(> Copy Fields                             || GET                    || [[http://localhost:8983/solr/schema/copyfields]]                      || source.fl, dest.fl                  ||                                             ||
- ||<(> Name                    ( <!> Solr 4.3) || GET                    || [[http://localhost:8983/solr/schema/name]]                            ||                                     ||                                             ||
- ||<(> Version                 ( <!> Solr 4.3) || GET                    || [[http://localhost:8983/solr/schema/version]]                         ||                                     ||                                             ||
- ||<(> Unique Key              ( <!> Solr 4.3) || GET                    || [[http://localhost:8983/solr/schema/uniquekey]]                       ||                                     ||                                             ||
- ||<(> Global Similarity       ( <!> Solr 4.3) || GET                    || [[http://localhost:8983/solr/schema/similarity]]                      ||                                     ||                                             ||
- ||<(> Default Query Operator  ( <!> Solr 4.3) || GET                    || [[http://localhost:8983/solr/schema/solrqueryparser/defaultoperator]] ||                                     ||                                             ||
- 
- === Query params ===
- 
- || '''param'''    || '''description'''                                                                                                                                                                                                        ||
- || showDefaults   || include in the response all default property values from the associated field type, e.g. {{{tokenized}}} for {{{solr.TextField}}}                                                                                        ||
- || includeDynamic || if the "fl" param is specified, matching dynamic fields are included in the response and identified with the {{{dynamicBase}}} property; if the "fl" param is not specified, the "includeDynamic" query param is ignored ||
- || fl             || restricts returned results to the value of this param, which can either be a single field or a comma- or space-separated list of fields                                                                                  ||
- || source.fl      || copyField source field list - see the "fl" param description                                                                                                                                                             ||
- || dest.fl        || copyField destination field list - see the "fl" param description                                                                                                                                                        ||
- 
- See CoreQueryParameters and CommonQueryParameters for descriptions of params not in the above table.
- 
- == Modifying the schema ==
- 
- <!> Solr 4.4
- 
- === Supported operations ===
- 
-  * Add field(s): Fields may be added to the schema if the field name(s) are not already in the schema, and if the field name(s) don't match any dynamicFields.
-  * Specify Copy Field(s): Copy Field directives may be added to the schema if both the source and all destination fields already exist in the schema.  You can specify copyFields either as part of an add field(s) operation via a PUT or POST to {{{schema/fields}}}, or as an independent operation via a POST to {{{schema/copyfields}}}. See [[https://issues.apache.org/jira/browse/SOLR-5010|SOLR-5010]] for more information.
- 
- === Required: Managed mutable schema ===
- 
- 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 [[https://issues.apache.org/jira/browse/SOLR-4658|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:
- 
- {{{#!xml
- <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 modifying the schema, will affect all other collections that use the same configset.
- 
- === Supported requests ===
- 
- Note that at present, only JSON format is supported for the body of these requests:
- 
- || '''Operation'''          || '''HTTP method''' || '''Example URL'''                                         || '''Example Body'''                                                                                                                                  || '''Supported query params'''        || '''Default params'''                        ||
- ||||||||<bgcolor="#F6F6FF">                                 '''All requests'''                                                                                                                                                                                       ||<bgcolor="#F6F6FF"> '''wt, indent''' ||<bgcolor="#F6F6FF"> '''?wt=json&indent=on''' ||
- ||<(|2> Add Field(s)        || PUT               || [[http://localhost:8983/solr/schema/fields/]]''newfield'' || {{{{"type":"text","stored":"false","copyFields":["target1",...]} }}}                                                                                ||                                     ||                                             ||
- ||                             POST              || [[http://localhost:8983/solr/schema/fields]]              || {{{[{"name":"newfield1","type":"text","copyFields":["target1",...]},}}}<<BR>>&nbsp;&nbsp;{{{{"name":"newfield2","type":"text","stored":"false"}]}}} ||                                     ||                                             ||
- || Specify Copy Field(s)    || POST              || [[http://localhost:8983/solr/schema/copyfields]]          || {{{[{"source":"sourceField","dest":["target1",...]}, ...] }}}                                                                                       ||                                     ||                                             ||
-