Solr中schema.xml的解释

 Solr-4.10.2与Tomcat整合
schema.xml位于D:\solr\data\solr\collection1\conf\中。
1、 fieldType节点
    name: FieldType的名称
    class: 指向org.apache.solr.analysis包里面对应的class名称,用来定义这个类型的行为
    omitNorms: 字段检索时被省略相关的规范
    positionIncrementGap:定义在同一个文档中此类型数据的空白间隔,避免短语匹配错误
    此外还可以建立索引和进行查询的时候要使用的分析器analyzer
2、 fields节点
    name:字段名
    type:之前定义过的各种FieldType
    indexed=true|false,是否被索引,如果一个字段设为true,那么它可以进行: earchable, sortable, facetable
    stored=true|false,是否被存储(如果不需要存储相应字段值,尽量设为false)
    default :字段的默认值
    compressed=true|false,true 使用gzip压缩存储(只适用 compressable;TextField和StrField)
    compressThreshold=<integer> 保证压缩到不小于一个大小
    multiValued=true|false,是否有多个值(对可能存在多值的字段尽量设置为true,避免建索引时抛出错误)
    omitNorms=true|false,true 则字段检索时被省略相关的规范
    omitTermFreqAndPositions=true|false,true 省略这一领域的长远频率,位置和有效载荷
3、 copyField复制节点
    source:数据来源,fields中的name
    dest: 目的地,fields中的name
4、 dynamicField动态节点
    name:字段名
    type:之前定义过的各种FieldType
    indexed=true|false,是否被索引,如果一个字段设为true,那么它可以进行: earchable, sortable, facetable
    stored=true|false,是否被存储(如果不需要存储相应字段值,尽量设为false)
5、 uniqueKey
    uniqueKey 设置字段惟一,<uniqueKey>user_id</uniqueKey>  
    文档的唯一标识, 必须填写这个field(除非该field被标记required="false"),否则solr建立索引报错。
6、 默认搜索字段
    <defaultSearchField>name</defaultSearchField>
    如果搜索参数中没有指定具体的field,那么这是默认的域。
7、 默认搜索类型
    <solrQueryParser defaultOperator="OR" />
    配置搜索参数短语间的逻辑,可以是"AND|OR"。
8、 < schema name =" example " version =" 1.2 " >
    name:标识这个schema的名字
    version:现在版本是1.2
9、为了改进性能,可以采取以下几种措施:
    将所有只用于搜索的,而不需要作为结果的field(特别是一些比较大的field)的stored设置为false
    将不需要被用于搜索的,而只是作为结果返回的field的indexed设置为false
    删除所有不必要的copyField声明
    为了索引字段的最小化和搜索的效率,将所有的 text fields的index都设置成field,然后使用copyField将他们都复制到一个总的 text field上,然后对他进行搜索。
    为了最大化搜索效率,使用java编写的客户端与solr交互(使用流通信)

    在服务器端运行JVM(省去网络通信),使用尽可能高的Log输出等级,减少日志量。

http://www.cnblogs.com/robertsun/p/4176783.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
以下是Solr 8.7.0版本的schema.xml模板,你可以根据自己的需求进行相应的修改。 ``` <?xml version="1.0" encoding="UTF-8"?> <schema name="example" version="1.6"> <types> <fieldType name="string" class="solr.StrField" sortMissingLast="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" /> <filter class="solr.EnglishMinimalStemFilterFactory" /> </analyzer> <analyzer type="query"> <tokenizer class="solr.StandardTokenizerFactory" /> <filter class="solr.StopFilterFactory" ignoreCase="true" words="stopwords.txt" /> <filter class="solr.SynonymGraphFilterFactory" synonyms="synonyms.txt" ignoreCase="true" expand="true" /> <filter class="solr.LowerCaseFilterFactory" /> <filter class="solr.EnglishMinimalStemFilterFactory" /> </analyzer> </fieldType> <fieldType name="date" class="solr.DatePointField" /> <fieldType name="int" class="solr.IntPointField" /> <fieldType name="long" class="solr.LongPointField" /> <fieldType name="float" class="solr.FloatPointField" /> <fieldType name="double" class="solr.DoublePointField" /> <fieldType name="boolean" class="solr.BoolField" /> </types> <fields> <field name="id" type="string" indexed="true" stored="true" multiValued="false" required="true" /> <field name="title" type="text_general" indexed="true" stored="true" multiValued="false" /> <field name="content" type="text_general" indexed="true" stored="true" multiValued="false" /> <field name="date" type="date" indexed="true" stored="true" multiValued="false" /> <field name="price" type="double" indexed="true" stored="true" multiValued="false" /> <field name="location" type="string" indexed="true" stored="true" multiValued="false" /> <field name="category" type="string" indexed="true" stored="true" multiValued="false" /> <field name="is_new" type="boolean" indexed="true" stored="true" multiValued="false" /> <dynamicField name="*_i" type="int" indexed="true" stored="true" multiValued="false" /> <dynamicField name="*_l" type="long" indexed="true" stored="true" multiValued="false" /> <dynamicField name="*_f" type="float" indexed="true" stored="true" multiValued="false" /> <dynamicField name="*_d" type="double" indexed="true" stored="true" multiValued="false" /> <dynamicField name="*_dt" type="date" indexed="true" stored="true" multiValued="false" /> </fields> <uniqueKey>id</uniqueKey> <defaultSearchField>content</defaultSearchField> <solrQueryParser defaultOperator="OR" /> </schema> ``` 其,该模板定义了一些常用的字段类型,如string、text_general、date、int、long、float、double和boolean等。同时,该模板还定义了一些常用的字段,如id、title、content、date、price、location、category和is_new等,以及动态字段。你可以根据自己的需求进行相应的添加和修改。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值