标签:
WiKi:https://cwiki.apache.org/confluence/display/solr/Schemaless+Mode
介绍:
Schemaless Mode is a set of Solr features that, when used together, allow users to rapidly construct an effective schema by simply indexing sample data, without having to manually edit the schema. These Solr features, all specified in solrconfig.xml, are:
配置:
1.Enable Managed Schema
As described in the section Managed Schema Definition in SolrConfig, changing the schemaFactory will allow the schema to be modified by the Schema API. Your solrconfig.xml should have a section like the one below (and the ClassicIndexSchemaFactory should be commented out or removed).
| <schemaFactoryclass="ManagedIndexSchemaFactory">  <boolname="mutable">true</bool>  <strname="managedSchemaResourceName">managed-schema</str></schemaFactory> | 
2.Define an UpdateRequestProcessorChain
The UpdateRequestProcessorChain allows Solr to guess field types, and you can define the default field type classes to use. To start, you should define it as follows (see the javadoc links below for update processor factory documentation):
| <updateRequestProcessorChainname="add-unknown-fields-to-the-schema">  <!-- UUIDUpdateProcessorFactory will generate an id if none is present in the incoming document -->  <processorclass="solr.UUIDUpdateProcessorFactory"/>  <processorclass="solr.LogUpdateProcessorFactory"/>  <processorclass="solr.DistributedUpdateProcessorFactory"/>  <processorclass="solr.RemoveBlankFieldUpdateProcessorFactory"/>  <processorclass="solr.FieldNameMutatingUpdateProcessorFactory">    <strname="pattern">[^\w-\.]</str>    <strname="replacement">_</str>  </processor>  <processorclass="solr.ParseBooleanFieldUpdateProcessorFactory"/>  <processorclass="solr.ParseLongFieldUpdateProcessorFactory"/>  <processorclass="solr.ParseDoubleFieldUpdateProcessorFactory"/>  <processorclass="solr.ParseDateFieldUpdateProcessorFactory">    <arrname="format">      <str>yyyy-MM-dd‘T‘HH:mm:ss.SSSZ</str>      <str>yyyy-MM-dd‘T‘HH:mm:ss,SSSZ</str>      <str>yyyy-MM-dd‘T‘HH:mm:ss.SSS</str>      <str>yyyy-MM-dd‘T‘HH:mm:ss,SSS</str>      <str>yyyy-MM-dd‘T‘HH:mm:ssZ</str>      <str>yyyy-MM-dd‘T‘HH:mm:ss</str>      <str>yyyy-MM-dd‘T‘HH:mmZ</str>      <str>yyyy-MM-dd‘T‘HH:mm</str>      <str>yyyy-MM-dd HH:mm:ss.SSSZ</str>      <str>yyyy-MM-dd HH:mm:ss,SSSZ</str>      <str>yyyy-MM-dd HH:mm:ss.SSS</str>      <str>yyyy-MM-dd HH:mm:ss,SSS</str>      <str>yyyy-MM-dd HH:mm:ssZ</str>      <str>yyyy-MM-dd HH:mm:ss</str>      <str>yyyy-MM-dd HH:mmZ</str>      <str>yyyy-MM-dd HH:mm</str>      <str>yyyy-MM-dd</str>    </arr>  </processor>  <processorclass="solr.AddSchemaFieldsUpdateProcessorFactory">    <strname="defaultFieldType">strings</str>    <lstname="typeMapping">      <strname="valueClass">java.lang.Boolean</str>      <strname="fieldType">booleans</str>    </lst>    <lstname="typeMapping">      <strname="valueClass">java.util.Date</str>      <strname="fieldType">tdates</str>    </lst>    <lstname="typeMapping">      <strname="valueClass">java.lang.Long</str>      <strname="valueClass">java.lang.Integer</str>      <strname="fieldType">tlongs</str>    </lst>    <lstname="typeMapping">      <strname="valueClass">java.lang.Number</str>      <strname="fieldType">tdoubles</str>    </lst>  </processor>  <processorclass="solr.RunUpdateProcessorFactory"/></updateRequestProcessorChain> | 
3.Make the UpdateRequestProcessorChain the Default for the UpdateRequestHandler
Once the UpdateRequestProcessorChain has been defined, you must instruct your UpdateRequestHandlers to use it when working with index updates (i.e., adding, removing, replacing documents). Here is an example using InitParams to set the defaults on all /updaterequest handlers:
| <initParamspath="/update/**">  <lstname="defaults">    <strname="update.chain">add-unknown-fields-to-the-schema</str>  </lst></initParams> | 
Solr特性:Schemaless Mode(自动往Schema中添加field)
标签:
原文地址:http://www.cnblogs.com/lvfeilong/p/345dgdfgf.html