solrcore的schema.xml

schema.xml文件在SolrCore的conf目录下,它是Solr数据表配置文件,在此配置文件中定义了域以及域的类型还有其他一些配置,在solr中域必须先定义后使用

<field name="id" type="string" indexed="true" stored="true" required="true" multiValued="false" />

Name:域的名称
Type:域的类型
Indexed:是否索引
Stored:是否存储
required:是否必须
multiValued:是否是多值,存储多个值时设置为true,solr允许一个Field存储多个值,比如存储一个用户的好友id(多个)

<!-- A general text field that has reasonable,generic cross-language defaults: it tokenizes with StandardTokenizer,removes stop words from case-insensitive "stopwords.txt" (empty by default),and down cases. At query time only,it also applies synonyms. -->
    <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" />
        <!-- in this example,we will only use synonyms at query time <filter class="solr.SynonymFilterFactory" synonyms="index_synonyms.txt" ignoreCase="true" expand="false"/> -->
        <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:指定过滤器

<uniqueKey>id</uniqueKey>

相当于主键,每个文档中必须有一个id域。

<copyField source="cat" dest="text" />

可以将多个Field复制到一个Field中,以便进行统一的检索。当创建索引时,solr服务器会自动的将源域的内容复制到目标域中。
source:源域
dest:目标域,搜索时,指定目标域为搜索域,可以提供查询效率
定义目标域

<!-- catchall field,containing all other searchable text fields (implemented via copyField further on in this schema -->
   <field name="text" type="text_general" indexed="true" stored="false" multiValued="true"/>
<dynamicField  name="*_i"  type="int"  indexed="true"  stored="true"/>

Name:动态域的名称,是一个表达式,*匹配任意字符,只要域的名称和表达式的规则能够匹配就可以使用。

例如:搜索查询条件【product_i:钻石】就可以匹配这个动态域,可以直接使用,不用单独再定义一个product_i域。

相关文章

php输出xml格式字符串
J2ME Mobile 3D入门教程系列文章之一
XML轻松学习手册
XML入门的常见问题(一)
XML入门的常见问题(三)
XML轻松学习手册(2)XML概念