solr官方文档翻译系列之schema.xml配置介绍 常见的元素 schema.xml概述 具体内容

solr官方文档翻译系列之schema.xml配置介绍
常见的元素
schema.xml概述
具体内容

<field name="weight" type="float" indexed="true" stored="true"/>
<dynamicField name="*_is" type="int" indexed="true" stored="true" multiValued="true"/>
<copyField source="cat" dest="text"/>

其中field和copyField是平时开发需要修改的地方 

schema.xml概述

schema.xml 文件包含所有的细节,这些细节包括你的多个文档可以包含哪些字段;添加多个文档到索引,或者查询这些字段的时候这些字段是如何处理的。

多条查询的分析可以单独指定,在大多数环境下可以自动处理小写字母通配符查询

这个例子schema是推荐给用户学习的入门例子。它应该保持正确性、简洁性、可用性、开箱即用。

执行需要注意的地方:这个schema包含许多可选的特性,不应该被用来作为基准例子。为了提高性能,我们可以这样做:

stored=false表示你只需要搜索到这个字段,但是不需要返回原始的值

indexed=false表示如果你不需要搜索这个字段,但是只是返回这个字段作为搜索其他索引字段的结果

删除所有不需要的copyField语句

为了最好的索引大小和搜索性能,对所有一般的text字段设置index=false,用copyField字段将他们拷贝到大杂烩text字段,使用text进行搜索

为了最大化索引的性能,使用多线程更新solr服务java客户端

记住以服务器模式运行JVM,使用更高级别的日子记录方式以避免日志记录每一个请求

具体内容

1、数据类型

<types>部分允许你定义一系列你想在schema中使用的<fieldtype>声明,以及类型会使用的底层的solr类,以及使用类型的字段的默认配置。

任何FieldType的子类必须作为一个字段类型类,要么使用它所有的包名,要么使用solr(如果它在默认的solr包中)。对于一般的数字类型,根据你的需求有多种实现方式。

请参照 SolrPlugins  了解如何确保你自己的一般字段类型被solr加载。

字段类型的一般选项包括:

    • sortMissingLast=true|false

    • sortMissingFirst=true|false

    • indexed=true|false

    • stored=true|false

    • multiValued=true|false

    • omitNorms=true|false

    • omitTermFreqAndPositions=true|false solr官方文档翻译系列之schema.xml配置介绍
常见的元素
schema.xml概述
具体内容 Solr1.4

    • omitPositions=true|false solr官方文档翻译系列之schema.xml配置介绍
常见的元素
schema.xml概述
具体内容 Solr3.4

    • positionIncrementGap=N

    • autoGeneratePhraseQueries=true|false (in schema version 1.4 and later this now defaults to false)

    • postingsFormat=<name of a postings format> solr官方文档翻译系列之schema.xml配置介绍
常见的元素
schema.xml概述
具体内容 Solr4.0, only works if you use a codec factory that is schema-aware such as SchemaCodecFactory. Please note that the postings formats used in a fieldType definition need to be in any of Solr lib directories. (For example, some useful (but unsupported) postings formats are available in the lucene-codecs JAR.). For detailed instructions on how to configure SimpleTextCodec, see: SimpleTextCodec Example

2、各种字段

2

2.1、推荐字段

3

2.2、一般字段选项

4

2.3、动态字段

5

2.4、多个字段中索引同样的内容

6

2.5、高级字段选项

7

3、 各种各样设置

8

参考文档:http://wiki.apache.org/solr/,http://wiki.apache.org/solr/SchemaXml。个人翻译理解不正确的地方,欢迎批评指正