如何更新elasticsearch中的字段类型 [英] How to update a field type in elasticsearch
本文介绍了如何更新elasticsearch中的字段类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
ElasticSearch 文档并不清楚如何执行此操作.
The ElasticSearch documents just aren't clear on how to do this.
我索引了一些推文,其中一个字段 created_at 被索引为字符串而不是日期.我找不到如何通过 curl 调用重新索引此更改.如果重新索引是一个复杂的过程,那么我宁愿删除那里的内容并重新开始.但是,我也找不到如何指定字段类型!
I indexed some tweets, and one of the fields, created_at, indexed as a string instead of a date. I can't find how to reindex with this change via a curl call. If reindexing is a complicated process, then I would much rather just delete what's there and start over. But, I can't find how to specify the field types either!
非常感谢任何帮助.
推荐答案
您需要使用 放置映射 API.
curl -XPUT 'http://localhost:9200/twitter/_doc/_mapping' -H 'Content-Type: application/json' -d '
{
"_doc" : {
"properties" : {
"message" : {"type" : "text", "store" : true}
}
}
}
'
日期可以定义如下:
curl -XPUT 'http://localhost:9200/twitter/_doc/_mapping' -H 'Content-Type: application/json' -d '
{
"_doc" : {
"properties" : {
"user" : {"type" : "keyword", "null_value" : "na"},
"message" : {"type" : "text"},
"postDate" : {"type" : "date"},
"priority" : {"type" : "integer"},
"rank" : {"type" : "float"}
}
}
}
'
这篇关于如何更新elasticsearch中的字段类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文