/// <summary> /// Create an index with the specified index settings /// </summary> public IndicesResponse CreateIndex(string index, IndexSettings settings) { string path = this.CreatePath(index); string data = JsonConvert.SerializeObject(settings, Formatting.None, SerializationSettings); var status = this.Connection.PostSync(path, data); var response = new IndicesResponse(); response.ConnectionStatus = status; try { response = JsonConvert.DeserializeObject <IndicesResponse>(status.Result); response.IsValid = true; } catch { } return(response); }
/// <summary> /// Clears the specified caches for only the indices passed under indices /// </summary> public IIndicesResponse ClearCache(IEnumerable <string> indices, ClearCacheOptions options) { string path = "/_cache/clear"; if (indices != null && indices.Any(s => !string.IsNullOrEmpty(s))) { indices = indices.Where(s => !string.IsNullOrEmpty(s)); path = this.PathResolver.CreateIndexPath(indices) + path; } if (options != ClearCacheOptions.All) { var caches = new List <string>(); if ((options & ClearCacheOptions.Id) == ClearCacheOptions.Id) { caches.Add("id=true"); } if ((options & ClearCacheOptions.Filter) == ClearCacheOptions.Filter) { caches.Add("filter=true"); } if ((options & ClearCacheOptions.FieldData) == ClearCacheOptions.FieldData) { caches.Add("field_data=true"); } if ((options & ClearCacheOptions.Bloom) == ClearCacheOptions.Bloom) { caches.Add("bloom=true"); } path += "?" + string.Join("&", caches.ToArray()); } ConnectionStatus status = this.Connection.PostSync(path, string.Empty); var response = new IndicesResponse(); try { response = this.Deserialize <IndicesResponse>(status.Result); response.IsValid = true; } catch { } response.ConnectionStatus = status; return(response); }
/// <summary> /// Deletes the mapping for the specified type name under the specified index /// </summary> public IIndicesResponse DeleteMapping(Type t, string index, string type) { string path = this.PathResolver.CreateIndexTypePath(index, type); ConnectionStatus status = this.Connection.DeleteSync(path); var response = new IndicesResponse(); try { response = this.Deserialize <IndicesResponse>(status.Result); } catch { } response.ConnectionStatus = status; return(response); }
public IndicesResponse DeleteMapping <T>(string index, string type) where T : class { string path = this.CreatePath(index, type); ConnectionStatus status = this.Connection.DeleteSync(path); var response = new IndicesResponse(); try { response = JsonConvert.DeserializeObject <IndicesResponse>(status.Result); } catch { } response.ConnectionStatus = status; return(response); }
public IndicesResponse Map <T>(string index, string type) where T : class { string path = this.CreatePath(index, type) + "_mapping"; string map = this.CreateMapFor <T>(type); ConnectionStatus status = this.Connection.PutSync(path, map); var response = new IndicesResponse(); try { response = JsonConvert.DeserializeObject <IndicesResponse>(status.Result); response.IsValid = true; } catch { } response.ConnectionStatus = status; return(response); }
/// <summary> /// <para>Automatically map an object based on its attributes, this will also explicitly map strings to strings, datetimes to dates etc even /// if they are not marked with any attributes.</para> /// <para> /// Type name is the specified type name under the specified index /// </para> /// </summary> public IIndicesResponse Map(Type t, string index, string type, int maxRecursion = 0) { string path = this.PathResolver.CreateIndexTypePath(index, type, "_mapping"); string map = this.CreateMapFor(t, type, maxRecursion); ConnectionStatus status = this.Connection.PutSync(path, map); var response = new IndicesResponse(); try { response = this.Deserialize <IndicesResponse>(status.Result); response.IsValid = true; } catch { } response.ConnectionStatus = status; return(response); }