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中定 ...
随机推荐
- java 几种常见的定时器
今天闲着没事就总结了一下在java中常用的几种定时器. 主要有3种java.util.Timer, ScheduledExecutorService和quartz 一.Timer 举个简单例子.每隔5 ...
- unity3d GameObject.Find 严格区分大小写的
GameObject.Find 查找 static function Find (name : string) : GameObject Description描述 Finds a game obje ...
- 2014多校第一场J题 || HDU 4870 Rating(DP || 高斯消元)
题目链接 题意 :小女孩注册了两个比赛的帐号,初始分值都为0,每做一次比赛如果排名在前两百名,rating涨50,否则降100,告诉你她每次比赛在前两百名的概率p,如果她每次做题都用两个账号中分数低的 ...
- POJ2002Squares
http://poj.org/problem?id=2002 题意 : 就是给你很多点的坐标,任取四个,看能组成多少个不同的正方形,相同的四个点,不同顺序构成的正方形视为同一正方形. 思路 : 就是一 ...
- php规范
PSR-0 自动加载 PSR-1 基本代码规范 PSR-2 代码样式 PSR-3 日志接口
- Android:ViewPager制作幻灯片
布局: <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:androi ...
- JAX-RS 方式的 RESTful Web Service 开发
JAX-RS 方式的 RESTful Web Service 开发 ——基于 CXF+Spring 的实现 Web Service 目前在风格上有两大类,一个是基于 SOAP 协议,一个是完全遵循 H ...
- 72. Edit Distance
题目: Given two words word1 and word2, find the minimum number of steps required to convert word1 to w ...
- pt-online-schema-change
[root@mysql5 ~]# pt-online-schema-change --alter=,u=root,p=1qaz2wsx,D=test,t=ddl_test --print --dry- ...
- VS2015中的异常配置
The New Exception Settings Window in Visual Studio 2015Managing Exceptions with the Debugger Underst ...