打开solrcore的conf目录,有一个managed-schema文件,里面配置field域,solr中所有的域都必须先配置后才可以使用。
- 定义field域
<field name="" type="" indexed="" stored="" required="" multiValued="" />
<!--
name:指定域名字
type:指定域类型,必须是后面fieldType定义的
indexed:指定是否索引
stored:指定是否存储
required:指定是否必须
multiValued:指定是否多值,比如一个物品多种图片
-->
- 定义动态域
<dynamicField name="" type="" indexed="" stored="" multiValued="" />
<!--
name:指定动态域的命名规则 *_xxx匹配以xxx结尾xxx_*以xxx_开始匹配
-->
- 指定唯一键
<uniqueKey>域名</uniqueKey>
<!--
必须是定义的field,必须required为true,一个文档中有且仅有一个唯一键
-->
- 复制键
<copyField source="" dest=""/>
<!--
source:要复制的源域的域名
dest:目标域必须设置multiValued为true
-->
- 定义域的类型
<fieldType name="text_general" class="solr.TextField" positionIncrementGap="100">
<analyzer type="index">
<tokenizer class="solr.StandardTokenizerFactory"/>
<filter class="solr.StopFilterFactory" ignoreCase="true" words="stopwords.txt" />
<filter class="solr.LowerCaseFilterFactory"/>
</analyzer>
<analyzer type="query">
<tokenizer class="solr.StandardTokenizerFactory"/>
<filter class="solr.StopFilterFactory" ignoreCase="true" words="stopwords.txt" />
<filter class="solr.SynonymFilterFactory" synonyms="synonyms.txt" ignoreCase="true" expand="true"/>
<filter class="solr.LowerCaseFilterFactory"/>
</analyzer>
</fieldType>
<!--
name:域类型的名称
class:指定域类型的solr类型。
analyzer:指定分词器。在FieldType定义的时候最重要的就是定义这个类型的数据在建立索引和进行查询的时候要使用的分析器analyzer,包括分词和过滤。
type:index和query。Index 是创建索引,query是查询索引。
tokenizer:指定分词器
filter:指定过滤器
-->