public void PrepareClose(ESConnection conn) { if (!IsOpen) { return; } ESIndexCmd cmd = createIndexCmd(conn); if (savedRefreshInterval != null) { JObject curSettings = new JObject(); curSettings["refresh_interval"] = savedRefreshInterval; cmd.PutSettings(curSettings); conn.Logger.Log("-- RefreshInterval restored to {0}", savedRefreshInterval); } cmd.Flush(IndexName); }
public bool Create(ESConnection conn, ESIndexCmd._CheckIndexFlags flags) { if (!Active) { return(false); } if (IsOpen) { return(false); } //Switch off append flags if there's nothing to append if (IndexDateTimeFormat == null || Generations == 0) { flags &= ~ESIndexCmd._CheckIndexFlags.AppendDate; } if (ReadOnly) { flags |= ESIndexCmd._CheckIndexFlags.DontCreate; } DocMappings = null; DateTime configDate; JObject configJson = onLoadConfig(this, ConfigFile, out configDate); patchConfig(conn, configJson); ESIndexCmd cmd = createIndexCmd(conn); cmd.OnCreate = overrideShardsOnCreate; bool isNew; IndexName = cmd.CheckIndexFromFile(AliasName, configJson, configDate, flags, out isNew);//PW naar kijken! IndexExists = IndexName != null; IsNewIndex = isNew; RenameNeeded = (flags & ESIndexCmd._CheckIndexFlags.AppendDate) != 0 && isNew; //Get possible mappings and determine default doctype conn.Logger.Log(""); conn.Logger.Log("get mappings"); DocMappings = new List <String>(); if (IndexName != null) //Might be null if the index was not found (if Readonly==true) { ESGetMappingResponse resp = cmd.GetIndexMappings(IndexName); conn.Logger.Log("Index[0]={0}", resp[0].Name); foreach (var mapping in resp[0]) { conn.Logger.Log("-- Mapping={0}", mapping.Name); DocMappings.Add(mapping.Name); } } if (RefreshIntervalDuringImport != null && !ReadOnly) { JObject curSettings = cmd.GetSettings(); this.savedRefreshInterval = curSettings.ReadStr("refresh_interval", "1s"); curSettings = new JObject(); curSettings["refresh_interval"] = RefreshIntervalDuringImport; cmd.PutSettings(curSettings); conn.Logger.Log("-- RefreshInterval changed from={0} into {1}", savedRefreshInterval, RefreshIntervalDuringImport); } IsOpen = true; return(isNew); }