2013-10-07 9 views
8

Ich lerne elasticsearch. Ich habe das Mapping in 'mapping.json' angegeben. Sein Inhalt sindcurl -X POST -d @ Mapping.json + Mapping nicht erstellt

{ 
    "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" 
      } 
     } 
    } 
} 

Die vorliegenden Abbildungen

$ 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-Mapping für Bücher erstellen mit dem Befehl

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

Aber wenn Liste alle Abbildungen, die ich erhalten:

$ 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" 
      } 
     } 
     } 
    } 
} 

warum ist das Mapping für nicht Bücher werden wie in der map.json-Datei angegeben erstellt?

+0

Hat einer der purposed Antworten lösen das Problem? – spuder

Antwort

11

Bitte versuchen Sie dies,

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

Befehl

curl -XPUT localhost:9200/_template/logstash -d @/Users/template.json 

Antwort

{"acknowledged":true} 
0

Auf AWS ich wie

einen Fehler bekam
{"error":"Content-Type header [application/x-www-form-urlencoded] is not supported","status":406} 

Um es zu beheben ich

hinzugefügt
-H 'Content-Type: application/json'