add index settings api
This commit is contained in:
parent
5e685f47c7
commit
05d5acd62c
|
@ -55,3 +55,41 @@ func (handler APIHandler) HandleGetIndicesAction(w http.ResponseWriter, req *htt
|
||||||
resBody["payload"] = catIndices
|
resBody["payload"] = catIndices
|
||||||
handler.WriteJSON(w, resBody, http.StatusOK)
|
handler.WriteJSON(w, resBody, http.StatusOK)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (handler APIHandler) HandleGetSettingsAction(w http.ResponseWriter, req *http.Request, ps httprouter.Params) {
|
||||||
|
client := elastic.GetClient(handler.Config.Elasticsearch)
|
||||||
|
indexName := ps.ByName("index")
|
||||||
|
resBody := newResponseBody()
|
||||||
|
indexes, err := client.GetIndexSettings(indexName)
|
||||||
|
if err != nil {
|
||||||
|
resBody["status"] = false
|
||||||
|
resBody["error"] = err
|
||||||
|
handler.WriteJSON(w, resBody, http.StatusOK)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
resBody["payload"] = indexes
|
||||||
|
handler.WriteJSON(w, resBody, http.StatusOK)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (handler APIHandler) HandleUpdateSettingsAction(w http.ResponseWriter, req *http.Request, ps httprouter.Params) {
|
||||||
|
client := elastic.GetClient(handler.Config.Elasticsearch)
|
||||||
|
indexName := ps.ByName("index")
|
||||||
|
settings := map[string]interface{}{}
|
||||||
|
resBody := newResponseBody()
|
||||||
|
err := handler.DecodeJSON(req, &settings)
|
||||||
|
if err != nil {
|
||||||
|
resBody["status"] = false
|
||||||
|
resBody["error"] = err
|
||||||
|
handler.WriteJSON(w, resBody, http.StatusOK)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
err = client.UpdateIndexSettings(indexName, settings)
|
||||||
|
if err != nil {
|
||||||
|
resBody["status"] = false
|
||||||
|
resBody["error"] = err
|
||||||
|
handler.WriteJSON(w, resBody, http.StatusOK)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
resBody["payload"] = true
|
||||||
|
handler.WriteJSON(w, resBody, http.StatusOK)
|
||||||
|
}
|
|
@ -31,6 +31,8 @@ func Init(cfg *config.AppConfig) {
|
||||||
ui.HandleUIMethod(api.DELETE, pathPrefix+"rebuild/:id", handler.HandleDeleteRebuildAction)
|
ui.HandleUIMethod(api.DELETE, pathPrefix+"rebuild/:id", handler.HandleDeleteRebuildAction)
|
||||||
ui.HandleUIMethod(api.GET, pathPrefix+"_cat/indices", handler.HandleGetIndicesAction)
|
ui.HandleUIMethod(api.GET, pathPrefix+"_cat/indices", handler.HandleGetIndicesAction)
|
||||||
ui.HandleUIMethod(api.GET, pathPrefix+"index/:index/_mappings", handler.HandleGetMappingsAction)
|
ui.HandleUIMethod(api.GET, pathPrefix+"index/:index/_mappings", handler.HandleGetMappingsAction)
|
||||||
|
ui.HandleUIMethod(api.GET, pathPrefix+"index/:index/_settings", handler.HandleGetSettingsAction)
|
||||||
|
ui.HandleUIMethod(api.PUT, pathPrefix+"index/:index/_settings", handler.HandleUpdateSettingsAction)
|
||||||
|
|
||||||
task.RegisterScheduleTask(task.ScheduleTask{
|
task.RegisterScheduleTask(task.ScheduleTask{
|
||||||
Description: "sync reindex task result to index infinireindex",
|
Description: "sync reindex task result to index infinireindex",
|
||||||
|
|
Loading…
Reference in New Issue