elasticsearch - 如何更新elasticsearch中的字段类型

标签 elasticsearch

ElasticSearch 文档并不清楚如何执行此操作。

我索引了一些推文,其中一个字段 created_at 被索引为字符串而不是日期。我找不到如何通过 curl 调用重新索引此更改。如果重建索引是一个复杂的过程,那么我宁愿删除那里的内容并重新开始。但是,我也找不到如何指定字段类型!

非常感谢任何帮助。

最佳答案

您需要使用 Put Mapping AP 定义一个映射一、

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 - 如何更新elasticsearch中的字段类型,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16290636/

相关文章:

c# - Elasticsearch NEST 搜索

elasticsearch - ID查询中ID的最大数量是多少?

Python日志分析工具/库

elasticsearch - Elastic search中的离线和在线索引是什么?什么时候需要重新索引?

regex - 在dls(文档级安全性)查询中使用正则表达式进行Elasticsearch过滤器访问

elasticsearch - 内部命中的聚合

php - 如何在Elasticsearch PHP中执行前缀查询?

elasticsearch - 从聚合结果中过滤空桶

Elasticsearch 版本最低兼容性字段

elasticsearch - Elasticsearch查询OR和AND函数