/// <summary> /// 创建更新Mapping /// </summary> /// <param name="index"></param> /// <param name="type"></param> /// <param name="mapping"></param> /// <returns></returns> public bool PutMapping(string index, string type, string mapping) { bool flag = false; StringResponse resStr = null; try { resStr = client.IndicesPutMapping <StringResponse>(index, type, PostData.String(mapping)); var resObj = JObject.Parse(resStr.Body); if ((bool)resObj["acknowledged"]) { flag = true; } else { LogUtil.LogInfo(logger, resStr.DebugInformation, nodeId); } } catch (Exception ex) { if (resStr != null) { LogUtil.LogInfo(logger, resStr.DebugInformation, nodeId); } LogUtil.LogError(logger, ex.ToString(), nodeId); } return(flag); }
/// <summary> /// Update mappings. /// </summary> /// <param name="type">Type name.</param> /// <param name="mapping">Modified mapping.</param> /// <returns>Updated mappings.</returns> protected FieldDefinitionList UpdateMapping(String type, String mapping) { ElasticsearchResponse <DynamicResponse> response; Debug.WriteLine("Update mapping = " + mapping); response = _client.IndicesPutMapping <DynamicResponse>(IndexName, type, mapping); CheckResponse(response); if (response.Body.IsNotNull() && (response.Body.Count > 0)) { return(GetMapping(type)); } else { return(null); } }