创建index时可以手动建立mapping,并且可以为mapping添加新的属性filed。但是,不能对已有的filed进行修改。
创建mapping:
PUT /website
{
"mappings": {
"article": { ---mapping名称
"properties": { ---属性filed
"author_id": {
"type": "long"
},
"title": {
"type": "text",
"analyzer": "english"
},
"content": {
"type": "text"
},
"post_date": {
"type": "date"
},
"publisher_id": {
"type": "text",
"index": "not_analyzed"
}
}
}
}
}
添加一个新的filed:
PUT /website/_mapping/article
{
"properties" : {
"new_field" : {
"type" : "string",
"index": "not_analyzed"
}
}
}
analyzed:进行分词
not_analyzed:不分词
no:不能索引