dynamic
true:插入值的字段没在mappings中定义,会新增字段
false:插入值的字段没在mappings中定义,不会新增字段,但也不会报错
strict:插入值的字段没在mappings中定义,会报错
PUT my_index
{
"mappings": {
"doc": {
"dynamic": false,
"properties": {
"title": {
"type": "text"
},
"name": {
"type": "keyword"
},
"age": {
"type": "integer"
}
}
}
}
}
GET my_index/_mapping
PUT my_index/doc/1
{
"title": "hello baozi",
"desc": "nothing"
}
GET my_index/doc/_search
{
"query": {
"match": {
"title": "hello"
}
}
}
GET my_index/doc/_search
{
"query": {
"match": {
"desc": "nothing"
}
}
}
copy_to
copy_to的字段不会被存储
PUT my_index
{
"mappings": {
"doc": {
"properties": {
"first_name": {
"type": "text",
"copy_to": "full_name"
},
"last_name": {
"type": "text",
"copy_to": "full_name"
},
"full_name": {
"type": "text"
}
}
}
}
}
PUT my_index/doc/1
{
"first_name": "B",
"last_name": "aozi"
}
GET my_index/doc/_search
{
"query": {
"match": {
"full_name": {
"query": "B aozi",
"operator": "and"
}
}
}
}
index
运行之后会保存,因为index设置为false
PUT my_index
{
"mappings": {
"doc": {
"properties": {
"cookie": {
"type": "text",
"index": false
}
}
}
}
}
PUT my_index/doc/1
{
"cookie": "name=baozi"
}
GET my_index/doc/_search
{
"query": {
"match": {
"cookie": "name"
}
}
}
index_options
用于控制倒排索引记录的内容,text类型默认为position
- docs 记录doc id
- freqs 记录doc id、term frequencies
- positions 记录doc id、term frequencies、term position
- offsets 记录doc id、term frequencies、term position和character offsets
null_value
遇到null值时怎么处理
网友评论