curl -X POST -d @ mapping.json +映射未创建 [英] curl -X POST -d @mapping.json + mapping not created

查看:953
本文介绍了curl -X POST -d @ mapping.json +映射未创建的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在学习弹性搜索。我在mapping.json中指定了映射。其内容为

I am learning elasticsearch. I have specified the mapping in 'mapping.json'. Its contents are

{
    "book" : {
         "_index" : {
             "enabled" : true
         },
         "_id" : {
             "index": "not_analyzed",
             "store" : "yes"
         },
        "properties" : {
            "author" : {
                "type" : "string"
            },
            "characters" : {
                "type" : "string"
            },
            "copies" : {
                "type" : "long",
                "ignore_malformed" : false
            },
            "otitle" : {
                "type" : "string"
            },
            "tags" : {
                "type" : "string"
            },
            "title" : {
                "type" : "string"
            },
            "year" : {
                "type" : "long",
                "ignore_malformed" : false,
                "index" : "analyzed"
            },
            "available" : {
                "type" : "boolean",
                "index" : "analyzed"
            }
        }
    }
}

目前的映射是

$ curl -XGET http://localhost:9200/_mapping?pretty
=> { 
   "development_users" : {
      "user" : {
         "properties" : {
            "email" : {
               "type" : "string"
            },
            "first_name" : {
               "type" : "string"
            },
            "id" : {
               "type" : "string",
               "index" : "not_analyzed",
               "omit_norms" : true,
               "index_options" : "docs",
               "include_in_all" : false
            },
            "last_name" : {
               "type" : "string"
            },
            "role" : {
               "type" : "string"
            }
         }
     }
  }
}

我使用命令创建书的映射

I create mapping for books using the command

$ curl http://localhost:9200/books -X POST -d @mapping.json
=> {"ok":true,"acknowledged":true}

但是列出所有映射:

$ curl -XGET http://localhost:9200/_mapping?pretty
=> { "books" : { },
   "development_users" : {
      "user" : {
         "properties" : {
            "email" : {
               "type" : "string"
            },
            "first_name" : {
               "type" : "string"
            },
            "id" : {
               "type" : "string",
               "index" : "not_analyzed",
               "omit_norms" : true,
               "index_options" : "docs",
               "include_in_all" : false
            },
            "last_name" : {
               "type" : "string"
            },
            "role" : {
               "type" : "string"
            }
         }
      }
   }
}

为什么不是在mapping.json文件中指定的图书的映射?

why isnt the mapping for books getting created as specified in mapping.json file?

推荐答案

curl -XPUT 'http://localhost:9200/<indexname>/book/_mapping' -d @mapping.json

这篇关于curl -X POST -d @ mapping.json +映射未创建的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆