update mapping with specify type
This commit is contained in:
parent
ca7c7d9ad6
commit
c6b9f30277
|
@ -976,9 +976,21 @@ func (h *APIHandler) initIndex(w http.ResponseWriter, req *http.Request, ps http
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if len(reqBody.Mappings) > 0 {
|
if ml := len(reqBody.Mappings); ml > 0 {
|
||||||
mappingBytes := util.MustToJSONBytes(reqBody.Mappings)
|
var (
|
||||||
_, err = client.UpdateMapping(indexName, mappingBytes)
|
docType = ""
|
||||||
|
mapping interface{} = reqBody.Mappings
|
||||||
|
)
|
||||||
|
if ml == 1 {
|
||||||
|
for key, _ := range reqBody.Mappings {
|
||||||
|
if key != "properties" {
|
||||||
|
docType = key
|
||||||
|
mapping = reqBody.Mappings[key]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
mappingBytes := util.MustToJSONBytes(mapping)
|
||||||
|
_, err = client.UpdateMapping(indexName, docType, mappingBytes)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error(err)
|
log.Error(err)
|
||||||
h.WriteError(w, err.Error(), http.StatusInternalServerError)
|
h.WriteError(w, err.Error(), http.StatusInternalServerError)
|
||||||
|
|
Loading…
Reference in New Issue