schema.xml配置文件是用于定义index索引库的结构,有点类似于数据表表的定义。

当我们打开schema.xml配置文件时,也许会被里面密密麻麻的代码所吓倒,其实不必惊慌,里面其实就两个东西filed和fieldType。

1、field–类似于数据表的字段

<fields>
      <field name="id" type="string" indexed="true" stored="true" required="true" multiValued="false" omitNorms="true"  default="df"/>
   .....//省略
  <field name="_version_" type="long" indexed="true" stored="true"/><!--此字段为最好不要删除哦!非要删除,请把solrconfig.xml中的updateLog注释,但不建议这样-->
</fields>
属性介绍:
(1)、name:字段名称
(2)、type:字段类型(此处type不是java类型,而是下面定义的fieldType)
(3)、indexed:是否索引?true--solr会对这个字段进行索引,只有经过索引的字段才能被搜索、排序等;false--不索引
(4)、stored:是否存储?true--存储,当我们需要在页面显示此字段时,应设为true,否则false。
(5)、required:是否必须?true--此字段为必需,如果此字段的内容为空,会报异常;false--不是必需
(6)、multiValued:此字段是否可以保存多个值?
(7)、omitNorms:是否对此字段进行解析?有时候我们想通过某个字段的完全匹配来查询信息,那么设置 indexed="true"、omitNorms="true"。
(8)、default:设置默认值

2、fieldType–字段类型

<types>
<fieldType name="string" class="solr.StrField" sortMissingLast="true" />
.....//省略
<fieldType name="text_general" positionIncrementGap="100">
        <analyzer type="index">
                    <tokenizer/>
                    <filter ignoreCase="true" words="stopwords.txt" enablePositionIncrements="true" />
                     <filter/>
        </analyzer>
        <analyzer type="query">
              <tokenizer/>
              <filter ignoreCase="true" words="stopwords.txt" enablePositionIncrements="true" />
               <filter synonyms="synonyms.txt" ignoreCase="true" expand="true"/>
                <filter/>
         </analyzer>
</fieldType>
</types>
属性说明:
(1)、name:类型名称,<field>中的type引用的就是这个name
(2)、class:solr自定义的类型
(3)、<analyzer type="index">定义建立索引时使用的分词器及过滤器
(4)、<analyzer type="query">定义搜索时所使用的分词器及过滤器
(5)、 <tokenizer/>定义分词器
(6)、<filter/>定义过滤器

3、uniqueKey

<uniqueKey>id</uniqueKey>
类似于数据表数据的id,solr索引库中最好定义一个用于标示document唯一性的字段,此字段主要用于删除document。

4、<copyField/>

<copyField source=”cat” dest=”text”/>
实际项目中为了方便查询,我们会把多个需要查询的字段合并到一个字段里,方便查询。

举例:

产品搜索,关键词不应该只匹配产品标题,还应该匹配产品关键词及产品简介等,那么在建立索引库时,可以把标题、产品关键词、简介放到一个叫text的字段中,搜索时直接搜text字段。

<fields>
     <field name="id" type="string" indexed="true" stored="true" required="true" multiValued="false" />
     <field name="title" type="text_general" indexed="true" stored="true"/>
     <field name="keywords" type="text_general" indexed="true" stored="true" omitNorms="true"/>
     <field name="description" type="string" indexed="true" stored="true" multiValued="true"/>
</fields> <copyField source="title" dest="text"/>
<copyField source="keywords" dest="text"/>
<copyField source="description" dest="text"/>

更多详细的内容请亲自研究schema.xml配置文件

本文出自luoshengsha.com,转载时请注明出处及相应链接。

本文永久链接: http://www.luoshengsha.com/213.html

solr4.5 schema.xml配置文件的更多相关文章

  1. solr4.2 solrconfig.xml配置文件简单介绍

    对于solr4.x的每个core有两个很重要的配置文件:solrconfig.xml和schema.xml,下面我们来了解solrconfig.xml配置文件. 具体很详细的内容请细读solrcofi ...

  2. mycat中间件--schema.xml配置文件详解

    schema.xml管理着MyCat的逻辑库.表.分片规则.DataNode以及DataSource.弄懂这些配置,是正确使用MyCat的前提. <?xml version="1.0& ...

  3. mycat schema.xml 配置文件详解

    <?xml version="1.0"?> <!DOCTYPE mycat:schema SYSTEM "schema.dtd"> &l ...

  4. solr的schema.xml配置文件关键词意义

    fieldType:配置扩展的分析器analyzer:具体的分析器的全路径field:配置具体的索引业务字段name:字段的名称type:指定使用哪种分析器域:StringField,textFiel ...

  5. 认识配置文件schema.xml(managed-schema)

    1.schema文件是在SolrConfig中的架构工厂定义,有两种定义模式: 1.1.默认的托管模式: solr默认使用的就是托管模式.也就是当在solrconfig.xml文件中没有显式声明< ...

  6. Solr5之Schema.xml详解

    schema.xml 是用来定义索引数据中的域的,包括域名称,域类型,域是否索引,是否分词,是否存储,是否标准化即 Norms ,是否存储项向量等等. schema.xml 配置文件的根元素就是 sc ...

  7. SOLR企业搜索平台 三 (schema.xml配置和solrj的使用)

    标签:solrj 原创作品,允许转载,转载时请务必以超链接形式标明文章 原始出处 .作者信息和本声明.否则将追究法律责任.http://3961409.blog.51cto.com/3951409/8 ...

  8. solr中的schema.xml(managed-schema)文件解读

    solr 7.2.1版本managed-schema文件示例 <uniqueKey>id</uniqueKey> 唯一键字段,solr对每一个文档都赋予一个唯一标识符字段,避免 ...

  9. Solr入门之(5)配置文件schema.xml

    该配置文件中的标签:<fileTypes>.<fields>.<uniqueKey>.<copyField> fieldType说明 标签types中定 ...

随机推荐

  1. hdu 1056

    水题 ~~  按题目要求直接判断~. /************************************************************************* > A ...

  2. hdu 1329 Hanoi Tower Troubles Again!

    找规律的题目an=an-1+(i+i%2)/2*2; ;}

  3. Hibernate中createCriteria即QBC查询的详细用法 .Hibernate中createCriteria即QBC查询的详细用法 .

    现在假设有一个Student类,内有id,name,age属性String hql = "from Student s";按照以前的做法,我们通常是Query query = se ...

  4. java 泛型类

     Java泛型中的标记符含义:  E - Element (在集合中使用,因为集合中存放的是元素) T - Type(Java 类) K - Key(键) V - Value(值) N - Numbe ...

  5. 什么叫非阻塞io

    而一个NIO的实现会有所不同,下面是一个简单的例子: ByteBuffer buffer = ByteBuffer.allocate(48); int bytesRead = inChannel.re ...

  6. Hibernate逍遥游记-第13章 映射实体关联关系-005双向多对多(使用组件类集合\<composite-element>\)

    1. <?xml version="1.0"?> <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hi ...

  7. PCB工艺镀金(电金)和沉金(化金)的区别

    1.镀金和沉金的别名分别是什么?   镀金:硬金,电金(镀金也就是电金) 沉金:软金,化金 (沉金也就是化金) 2.别名的由来:  镀金:通过电镀的方式,使金粒子附着到pcb板上,所以叫电金,因为附着 ...

  8. 利用python 获取 windows 组策略

    工作中有时候会有这种需求: 1. 自动配置组策略的安全基线,这个东西不用你自己写了,微软有这个工具,Microsoft Security Compliance Manager,你可以在下面的地址去下载 ...

  9. Windows下获取高精度时间注意事项

    Windows下获取高精度时间注意事项 [转贴 AdamWu]   花了很长时间才得到的经验,与大家分享. 1. RDTSC - 粒度: 纳秒级 不推荐优势: 几乎是能够获得最细粒度的计数器抛弃理由: ...

  10. 244. Shortest Word Distance II

    题目: This is a follow up of Shortest Word Distance. The only difference is now you are given the list ...