加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

solrcore的schema.xml

发布时间:2020-12-16 02:02:37 所属栏目:百科 来源:网络整理
导读:schema.xml文件在SolrCore的conf目录下,它是Solr数据表配置文件,在此配置文件中定义了域以及域的类型还有其他一些配置,在solr中域必须先定义后使用 field name= "id" type = "string" indexed= "true" stored= "true" required= "true" multiValued= "fal

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域。

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读