搜索结果正在快递途中

创建索引的时候,字段的类型由ES系统指定,是否可以改变这个行为

Elasticsearch | 作者 gh | 发布于2017年09月04日 | 阅读数:5853

我通过以下语句创建一个索引:
POST /oplog_v2/goods/
{
"title": "My second blog entry",
"text": "Still trying this out...",
"date": "2014-01-01 09:01:10"
}

date字段类型竟然是text,我期望是date类型:
{
"oplog_v2": {
"mappings": {
"goods": {
"properties": {
"date": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"text": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"title": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
}
}
}
}
}
}
已邀请:

kennywu76 - Wood

赞同来自: laoyang360

创建索引的时候,指定好mapping即可。

Cheetah

赞同来自:

已经创建好之后就不能更改了,不过5.0有reindex api,可以用这个重新索引,在索引之前请建好mapping

zhangyufu - 学习使我快乐

赞同来自:

不想每次手动创建,建议使用模板控制字段映射类型

gh

赞同来自:

学习了 感谢大家
curl -XPUT "http://localhost:9200/testindex/" -H 'Content-Type: application/json' -d'
{

"mappings": {

"logs": {

"properties": {

"product": {

"type": "string"

}

}

}

}

}'

wanyanglan - 90后

赞同来自:

`}NDYK~CNIIYPAR{JI42AH6.png

想给时间字段添加不被分词效果怎么去修改mapping
 

要回复问题请先登录注册