ElasticSearch文档只是不清楚如何执行此操作。如何更新elasticsearch中的字段类型
我将一些推文编入索引,其中一个字段created_at索引为字符串而不是日期。我无法通过curl调用找到如何通过此更改重新索引。如果reindexing是一个复杂的过程,那么我宁愿删除那里的东西,然后重新开始。但是,我找不到如何指定字段类型!
任何帮助,非常感谢。
ElasticSearch文档只是不清楚如何执行此操作。如何更新elasticsearch中的字段类型
我将一些推文编入索引,其中一个字段created_at索引为字符串而不是日期。我无法通过curl调用找到如何通过此更改重新索引。如果reindexing是一个复杂的过程,那么我宁愿删除那里的东西,然后重新开始。但是,我找不到如何指定字段类型!
任何帮助,非常感谢。
您需要定义使用Put Mapping AP一
$ curl -XPUT 'http://localhost:9200/twitter/tweet/_mapping' -d '
{
"tweet" : {
"properties" : {
"message" : {"type" : "string", "store" : "yes"}
}
}
}
'
日期的映射可以被定义如下:
{
"tweet" : {
"properties" : {
"user" : {"type" : "string", "index" : "not_analyzed"},
"message" : {"type" : "string", "null_value" : "na"},
"postDate" : {"type" : "date"},
"priority" : {"type" : "integer"},
"rank" : {"type" : "float"}
}
}
}
您还需要指定格式,如果要插入不只是输入MySQL的时间戳,那么你应该只是像这样添加一个格式。
"properties": {
"updated_at": {
"type": "date",
"format": "yyyy-MM-dd HH:mm:ss"
}
}
如果我们考虑你的榜样,那么它应该像
"tweet" : {
"properties" : {
"user" : {"type" : "string", "index" : "not_analyzed"},
"message" : {"type" : "string", "null_value" : "na"},
"postDate" : {"type" : "date" , "format": "yyyy-MM-dd HH:mm:ss" },
"priority" : {"type" : "integer"},
"rank" : {"type" : "float"}
}
}
是的,就是这样。谢谢你dadoonet。 – maximus 2013-04-30 20:00:22
@dadoonet任何方式来改变“消息”字段类型从字符串更改为“长”.Merge失败{{[mapper [消息]不同类型,current_type [字符串] – Dibish 2015-03-05 05:08:00
@dibish号您需要reindex。 – dadoonet 2015-03-05 08:35:17