elasticsearch,Curl,elasticsearch" /> elasticsearch,Curl,elasticsearch" />

curl-X POST-d@mapping.json+;未创建映射

curl-X POST-d@mapping.json+;未创建映射,curl,elasticsearch,Curl,elasticsearch,我正在学习弹性搜索。我已经在“mapping.json”中指定了映射。它的内容是 { "book" : { "_index" : { "enabled" : true }, "_id" : { "index": "not_analyzed", "store" : "yes" }, "properties" : {

我正在学习弹性搜索。我已经在“mapping.json”中指定了映射。它的内容是

{
    "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"
            }
         }
     }
  }
}
我使用命令为书籍创建映射

$ 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文件中的指定创建图书映射?

请尝试此操作

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

命令

curl -XPUT localhost:9200/_template/logstash -d @/Users/template.json   
{"acknowledged":true}
响应

curl -XPUT localhost:9200/_template/logstash -d @/Users/template.json   
{"acknowledged":true}

在AWS上我犯了一个错误

{"error":"Content-Type header [application/x-www-form-urlencoded] is not supported","status":406}
为了解决这个问题,我又加了一句

-H 'Content-Type: application/json'

有没有任何有目的的答案解决了这个问题?就我而言,提供
http://locahost:9200//
(也就是说,我不需要“书本映射”)。