【问题标题】:Elasticsearch 7 unable to create indexElasticsearch 7 无法创建索引
【发布时间】:2019-08-21 14:07:03
【问题描述】:

我正在尝试使用以下语法创建索引

curl -H "Content-Type: application/json" -XPUT 127.0.0.1:9200/movies -d '
{
    "mappings": {
        "movie": {
            "properties": {
                "year": {"type":"date"}
            }
        }
    }
}'

我猜“电影”不能是“映射”的子元素,有人可以帮我把它转换成 Elasticsearch 7 兼容的语法。

我尝试使用"movie.year" : {"type":"date"},但随后在插入语句中失败

curl -H "Content-Type: application/json" -XPUT 127.0.0.1:9200/movies/movie/109487 -d '
{
    "genre":["IMAX", "Sci-Fi"],
    "title":"Intersteller",
    "year":2014
}'

我从 Elasticsearch 6 的教程中复制的

“拒绝对 [movies] 的映射更新,因为最终映射会 超过 1 种类型:[_doc,movie]"

【问题讨论】:

    标签: elasticsearch


    【解决方案1】:

    在 ES 7 中,有no more types。你需要这样做。

    首先,create the index

    curl -H "Content-Type: application/json" -XPUT 127.0.0.1:9200/movies -d '
    {
        "mappings": {
            "properties": {
                "year": {"type":"date"}
            }
        }
    }'
    

    那么,index your document:

    curl -H "Content-Type: application/json" -XPUT 127.0.0.1:9200/movies/_doc/109487 -d '
    {
        "genre":["IMAX", "Sci-Fi"],
        "title":"Intersteller",
        "year":2014
    }'
    

    【讨论】:

    • 非常感谢,您分享的链接丢失了。
    • 太棒了,很高兴它有帮助!
    猜你喜欢
    • 2021-07-10
    • 2016-01-19
    • 1970-01-01
    • 1970-01-01
    • 2020-05-31
    • 1970-01-01
    • 2013-09-12
    • 2020-03-20
    • 1970-01-01
    相关资源
    最近更新 更多