solr4.5 schema.xml配置文件
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配置文件的更多相关文章
- solr4.2 solrconfig.xml配置文件简单介绍
对于solr4.x的每个core有两个很重要的配置文件:solrconfig.xml和schema.xml,下面我们来了解solrconfig.xml配置文件. 具体很详细的内容请细读solrcofi ...
- mycat中间件--schema.xml配置文件详解
schema.xml管理着MyCat的逻辑库.表.分片规则.DataNode以及DataSource.弄懂这些配置,是正确使用MyCat的前提. <?xml version="1.0& ...
- mycat schema.xml 配置文件详解
<?xml version="1.0"?> <!DOCTYPE mycat:schema SYSTEM "schema.dtd"> &l ...
- solr的schema.xml配置文件关键词意义
fieldType:配置扩展的分析器analyzer:具体的分析器的全路径field:配置具体的索引业务字段name:字段的名称type:指定使用哪种分析器域:StringField,textFiel ...
- 认识配置文件schema.xml(managed-schema)
1.schema文件是在SolrConfig中的架构工厂定义,有两种定义模式: 1.1.默认的托管模式: solr默认使用的就是托管模式.也就是当在solrconfig.xml文件中没有显式声明< ...
- Solr5之Schema.xml详解
schema.xml 是用来定义索引数据中的域的,包括域名称,域类型,域是否索引,是否分词,是否存储,是否标准化即 Norms ,是否存储项向量等等. schema.xml 配置文件的根元素就是 sc ...
- SOLR企业搜索平台 三 (schema.xml配置和solrj的使用)
标签:solrj 原创作品,允许转载,转载时请务必以超链接形式标明文章 原始出处 .作者信息和本声明.否则将追究法律责任.http://3961409.blog.51cto.com/3951409/8 ...
- solr中的schema.xml(managed-schema)文件解读
solr 7.2.1版本managed-schema文件示例 <uniqueKey>id</uniqueKey> 唯一键字段,solr对每一个文档都赋予一个唯一标识符字段,避免 ...
- Solr入门之(5)配置文件schema.xml
该配置文件中的标签:<fileTypes>.<fields>.<uniqueKey>.<copyField> fieldType说明 标签types中定 ...
随机推荐
- 使用tornado让你的请求异步非阻塞
http://www.dongwm.com/archives/shi-yong-tornadorang-ni-de-qing-qiu-yi-bu-fei-zu-sai/?utm_source=tuic ...
- hdu 1180 诡异的楼梯(广搜,简单)
题目 挺简单的一道广搜题,只要用判断时间是偶数还是奇数就可以判断楼梯的方位,但是我这傻逼居然写了那么久啊那么久,我果然秀逗了,,,, #define _CRT_SECURE_NO_WARNINGS # ...
- http://www.aboutyun.com/thread-6551-1-1.html
http://www.aboutyun.com/thread-6551-1-1.html
- 李洪强漫谈iOS开发[C语言-010] - C语言简要复习
// // main.m // 05 - 简要复习 // // Created by vic fan on 16/7/13. // Copyright © 2016年 李洪强. All rig ...
- lintcode:Compare Strings 比较字符串
题目: 比较字符串 比较两个字符串A和B,确定A中是否包含B中所有的字符.字符串A和B中的字符都是 大写字母 样例 给出 A = "ABCD" B = "ACD" ...
- *[codility]MinAvgTwoSlice
https://codility.com/demo/take-sample-test/min_avg_two_slice 此题要求一个数组子段的最小的平均数(返回第一个数字的index).刚开始想记录 ...
- activiti5.13 框架 数据库设计说明书
转载自:http://www.cnblogs.com/llzgzljl/p/3356108.html activiti5.13 框架 数据库设计说明书 1.结构设计 1.1. 逻辑结构设计 Ac ...
- springMVC获取request和response
转载:http://blog.sina.com.cn/s/blog_7085382f0102v9jg.html 1.参数 例如: @RequestMapping("/test") ...
- SULogger:iOS日志可视化工具
前言 debug对于咋们程序员来说家常便饭,但有时候我们会遇到一种情况:开发某个功能时,需要在某个特定场景下进行调试,而这个场景并没有MacBook来进行连接debug,偏偏我们需要获得调试时的一些信 ...
- CreateTwoArray
public class CreateTwoArray{ public static void main(String []args){ int[][]arr=new int [2][3]; Syst ...