如何更新弹性搜索中的字段类型 [英] How to update a field type in elasticsearch
本文介绍了如何更新弹性搜索中的字段类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
ElasticSearch文件对于如何执行此操作并不清楚。
The ElasticSearch documents just aren't clear on how to do this.
我索引了一些tweets,其中一个字段created_at被索引为字符串而不是日期。通过卷曲调用,我无法找到如何使用此更改来重建索引。如果重新索引是一个复杂的过程,那么我更愿意删除那些内容并重新开始。但是,我找不到如何指定字段类型!
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!
非常感谢任何帮助。
推荐答案
您需要定义使用 Put Mapping AP 的映射I。
You need to define a mapping using Put Mapping API.
$ curl -XPUT 'http://localhost:9200/twitter/tweet/_mapping' -d '
{
"tweet" : {
"properties" : {
"message" : {"type" : "string", "store" : "yes"}
}
}
}
'
日期可以定义如下: / p>
A date can be defined as follow:
{
"tweet" : {
"properties" : {
"user" : {"type" : "string", "index" : "not_analyzed"},
"message" : {"type" : "string", "null_value" : "na"},
"postDate" : {"type" : "date"},
"priority" : {"type" : "integer"},
"rank" : {"type" : "float"}
}
}
}
这篇关于如何更新弹性搜索中的字段类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文