Solr的基本使用

Solr的基本使用

1.1 Schema.xml

在schema.xml文件中,主要配置了solrcore的一些数据信息,包括Field和FieldType的定义等信息,在solr中Field和FieldType都需要先定义后使用

 1.1.1 Filed

定义Field域

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

 Name:指定域的名称

Type:指定域的类型

Indexed:是否索引

Stored:是否存储

Required:是否必须

multiValued:是否多值,比如商品信息中,一个商品有多张图片,一个Field像存储多个值的话,必须将multiValued设置为true。

 1.1.2 dynamicField

动态域

<dynamicField name="*_i"  type="int"    indexed="true"  stored="true"/>

 Name:指定动态域的命名规则

 1.1.3 uniqueKey

指定唯一键

 <uniqueKey>id</uniqueKey>

 其中的id是在Field标签中已经定义好的域名,而且该域要设置为required为true。

 一个schema.xml文件中必须有且仅有一个唯一键

1.1.4 copyField

复制域

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

 Source:要复制的源域的域名

Dest:目标域的域名

由dest指的的目标域,必须设置multiValued为true。

 1.5 FieldType

定义域的类型

<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:指定分析器

Type:index、query,分别指定搜索和索引时的分析器

Tokenizer:指定分词器

Filter:指定过滤器

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值