Solr之模式配置Schema.xml。
来源:互联网 发布:java 二维码 原理 编辑:程序博客网 时间:2024/05/22 11:37
schema.xml这个配置文件可以在你下载solr包的安装解压目录的\solr\example\solr\collection1\conf中找到,他就是solr模式关联的文件。打开这个配置文件,会发现有详细的注释。模式组织主要分为三个重要配置。
types部分
是一些常见的可重用定义,定义了Solr(和Lucene)如何处理Field。也就是添加到索引中的xml文件属性中的类型,如int、text、date等。
<fieldType name = "string" class = "solr.StrField" sortMissingLast = "true" />
<fieldType name = "boolean" class = "solr.BoolField" sortMissingLast = "true" />
<fieldType name = "int" class = "solr.TrieIntField" precisionStep = "0" positionIncrementGap = "0" />
<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" enablePositionIncrements = "true" />
<filter class = "solr.LowerCaseFilterFactory" />
</analyzer>
<analyzer type = "query">
<tokenizer class = "solr.StandardTokenizerFactory" />
<filter class = "solr.StopFilterFactory" ignoreCase = "true" words = "stopword.txt" enablePositionIncrements = "true" />
<filter class = "solr.SynonymFilterFactory" synonyms = "synonyms.txt" ignoreCase = "true" expand = "true" />
<filter class = "solr.LowerCaseFilterFactory" />
</analyzer>
</fieldType>
参数说明:
属性
描述
name标识而已class和其他属性决定了这个fieldType的十几行为。sortMissingLast设置成true没有该field的数据排在有该field的数据之后,而不管请求时的排序规则,默认是设置成false。sortMissingFirst跟上面倒过来,默认是设置成false。analyzer字段类型指定的分词器。type当前分词用于操作的.index代表生成索引时使用的分词器query代码在查询时使用的分词器tokenizer分词器类filter分词后应用的过滤器,过滤器调用顺序和配置相同。
fields
是你添加到索引文件中出现的属性名称,而声明类型就需要用到上面的types。
<field name = "id" type = "string" indexed = "true" stored = "true" required = "true" multiValued = "false" />
<field name = "path" type = "text_smartcn" indexed = "false" stored = "true" multiValued = "false" termVector = "true" />
<field name = "content" type = "text_smartcn" indexed = "false" stored = "true" multiValued = "false" termVector = "true" />
<field name = "text" type = "text_ik" indexed = "true" stored = "false" multiValued = "false" />
<field name = "pinyin" type = "text_pinyin" indexed = "true" stored = "false" multiValued = "false" />
<field name = "_version" type = "long" indexed = "true" stored = "true" />
<dynamicField name = "*_i" type = "int" indexed = "true" stored = "true" />
<dynamicField name = "*_l" type = "long" indexed = "true" stored = "true" />
<dynamicField name = "*_s" type = "string" indexed = "true" stored = "true" />
- field:固定的字段设置。
- dynamicField:动态的字段设置,用于后期自定义字段,*号通配符,例如:test_i就是int类型的动态字段。
还有一个特殊的字段是copyField,一般用于检索时用的字段这样就只对这一个字段进行索引分词就行了,copyField的dest字段如果有多个source一定要设置multiValue=true,否则会报错的。
另外,使用copyField将多个field都复制到一个总的field上,然后对他进行搜索,可以最小化索引字段并且提高搜索的效率。
<copyField source = "content" dest = "pinyin" />
<copyField source = "content" dest = "text" />
<copyField source = "pinyin" dest = "text" />
字段属性说明:
属性 描述 name字段类型名classjava类名indexed缺省true。 说明这个数据应被搜索和排序,如果数据没有indexed,则stored应是true。stored缺省true。说明这个字段被包含在搜索结果中是合适的。如果数据没有stored,则indexed应是true。omitNorms字段的长度不影响得分和在索引时不做boost时,设置他为true。一般文本字段不设置为true。termVectors如果字段被用来做more like this 和highlight的特性时应设置为true。compressed字段是压缩的。这可能导致索引和搜索变慢,但会减少存储空间,只有StrField和TextField是可以压缩,这糖厂适合字段的长度超过200个字符。multiValued字段多于一个值得时候,可设置为true。positionIncrementGap和multiValued一起使用,设置多个值之间的虚拟空白的数量。注意:_version_是一个特殊字段,不能删除;是记录当前索引版本号的。
其他配置
- uniqueKey:唯一键,这里配置的是上面出现的fields,一般是id、url等不重复的。在更新、删除的时候可以用到。
- defaultSearchField:默认搜索属性,如q=solr就是默认的搜索那个字段。
- solrQueryParser:查询转换模式,是并且还是或者(AND/OR必须大写)。
- Solr之模式配置Schema.xml。
- Solr之Schema.xml
- solr schema.xml配置总结
- solr配置schema.xml学习
- Solr schema.xml配置详解
- Solr 配置文件之schema.xml
- solr之schema.xml中文翻译
- Solr 配置文件之schema.xml
- solr schema.xml 的配置说明
- Solr-6.5.1 配置schema.xml
- (搜索引擎之solr) schema.xml 配置文件说明
- (搜索引擎之solr) schema.xml 配置文件说明
- Solr基础教程之Schema.xml(二)
- Solr主要配置文件之schema.xml。
- solr schema.xml 解析
- solr的schema.xml
- solr schema.xml
- solr schema.xml
- Webpack创建、运行vue.js项目及其目录结构详解
- ssm框架搭建
- 第九周项目1---二叉树算法库
- ETC通行费9折活动
- recyclerview单击事件和多条目点击事件
- Solr之模式配置Schema.xml。
- 为什么新网vps直接用ip访问无法打开网站?
- java中重载与重写的区别
- qualcomm linux平台编译环境搭建及编译说明
- SQL Server数据库添加数据时中文乱码
- 第九周 【项目1
- 有秒计时的数字时钟
- 第七周-项目4
- 存储过程入门