schema.xml中配置的是索引库 域字段和域字段的类型
1)
字段属性:
<field name="id" type="string" indexed="true" stored="true" required="true" />
indexed: 如果字段需要被索引(用于搜索或排序),属性值设置为true,为false该字段就是有值也不能被检索到
stored: 如果字段内容需要被返回显示,值设置为true;为falses时 字段还是能被分词后存成索引,但该字段完整的值并没被保存
就是搜素匹配成功,也没法展示该字段的值。
multiValued: 如果这个字段在每个文档中可能包含多个值,设置为true
定义复制域字段的时候,设置
<field name="ta" type="text" indexed="true" stored="false" multiValued="true"/>
<copyField source="t" dest="ta" />
- <copyField source="a" dest="ta" />
required:为true 该字段必须有值 不能为空,否则会抛异常
default: 在增加文档时,可以根据需要为字段设置一个默认值,防止为空
2).复制域字段
maxChars 参数,用于限制复制的字符数。
<
copyField
source
=
"*_t"
dest
=
"text"
maxChars
=
"25000"
/>
source和destination都支持通配符。以下是一个将所有以 _t 结尾的字段全部复制到text字段中
<
copyField
source
=
"*_t"
dest
=
"text"
maxChars
=
"25000"
/>
3).动态域字段dynamicField
不管分词存储还检索的时候,输入的字段先去常规字段中匹配,如果没有匹配到就来匹配动态字段,
例如mydata_i 或者youdata_i的数据都会存储到*_i动态字段中(把它当做 一个字段),检索的时候,如果_i结尾且常规没匹配到就从*_i字段(看做一个字段)匹配
<
dynamicField
name
=
"*_i"
type
=
"sint"
indexed
=
"true"
stored
=
"true"
/>
|
建议在 schema.xml 定义一些基本的动态字段,以备扩展之用。