private string AppendDeleteByQueryParametersToPath(string path, DeleteByQueryParameters urlParameters) { if (urlParameters == null) { return(path); } var parameters = new List <string>(); if (urlParameters.Replication != Replication.Sync) //sync == default { parameters.Add("replication=" + urlParameters.Replication.ToString().ToLower()); } if (urlParameters.Consistency != Consistency.Quorum) //quorum == default { parameters.Add("consistency=" + urlParameters.Replication.ToString().ToLower()); } if (!urlParameters.Routing.IsNullOrEmpty()) { parameters.Add("routing=" + urlParameters.Routing); } path += "?" + string.Join("&", parameters.ToArray()); return(path); }
public void DeleteByQueryOverAllAsync <T>(string query, DeleteByQueryParameters parameters, Action <ConnectionStatus> callback) where T : class { query.ThrowIfNullOrEmpty("query"); var path = this.CreatePath("_all", "_query"); if (parameters != null && !parameters.Equals(default(DeleteByQueryParameters))) { path = this.AppendDeleteByQueryParametersToPath(path, parameters); } this._deleteToPathAsync(path, query, callback); }
public ConnectionStatus DeleteByQueryOverAll <T>(string query, DeleteByQueryParameters parameters) where T : class { query.ThrowIfNullOrEmpty("query"); var path = this.CreatePath("_all", "_query"); if (parameters != null && !parameters.Equals(default(DeleteByQueryParameters))) { path = this.AppendDeleteByQueryParametersToPath(path, parameters); } return(this._deleteToPath(path, query)); }
public Task <IDeleteResponse> DeleteByQueryAsync(string query, DeleteByQueryParameters parameters = null) { var descriptor = new RoutingQueryPathDescriptor(); var path = this.PathResolver.GetPathForDynamic(descriptor, "_query"); if (parameters != null) { path = this.PathResolver.AppendDeleteByQueryParametersToPath(path, parameters); } return(this._deleteToPathAsync(path, query)); }
public Task <ConnectionStatus> DeleteByQueryAsync(string query, DeleteByQueryParameters parameters = null) { var descriptor = new QueryPathDescriptor(); var path = this.GetPathForDynamic(descriptor); if (parameters != null) { path = this.AppendDeleteByQueryParametersToPath(path, parameters); } return(this._deleteToPathAsync(path, query)); }
public void DeleteByQueryAsync <T>(string query, string index, string type, DeleteByQueryParameters parameters, Action <ConnectionStatus> callback) where T : class { query.ThrowIfNullOrEmpty("query"); index.ThrowIfNullOrEmpty("index cannot be empty"); type.ThrowIfNullOrEmpty("type cannot be empty"); var path = this.CreatePath(index, type, "_query"); if (parameters != null && !parameters.Equals(default(DeleteByQueryParameters))) { path = this.AppendDeleteByQueryParametersToPath(path, parameters); } this._deleteToPathAsync(path, query, callback); }
public ConnectionStatus DeleteByQuery <T>(string query, string index, DeleteByQueryParameters parameters) where T : class { query.ThrowIfNullOrEmpty("query"); index.ThrowIfNullOrEmpty("index cannot be empty"); var typeName = this.InferTypeName <T>(); var path = this.CreatePath(index, typeName, "_query"); if (parameters != null && !parameters.Equals(default(DeleteByQueryParameters))) { path = this.AppendDeleteByQueryParametersToPath(path, parameters); } return(this._deleteToPath(path, query)); }
/// <summary> /// Deletes all documents that match the query, without specifying T the return documents is an IEnumerable<dynamic> /// </summary> /// <param name="query">QueryPathDescriptor also allows you to control which indices and types are affected</param> /// <param name="parameters">Control routing/consistency and replication</param> /// <returns>ConnectionStatus, check .IsValid to validate success</returns> public ConnectionStatus DeleteByQuery(Action <QueryPathDescriptor> query, DeleteByQueryParameters parameters = null) { var descriptor = new QueryPathDescriptor(); query(descriptor); var stringQuery = ElasticClient.Serialize(descriptor); var path = this.GetPathForDynamic(descriptor); if (parameters != null) { path = this.AppendDeleteByQueryParametersToPath(path, parameters); } return(this._deleteToPath(path, stringQuery)); }
public void DeleteByQueryAsync <T>(string query, DeleteByQueryParameters parameters, Action <ConnectionStatus> callback) where T : class { query.ThrowIfNullOrEmpty("query"); var index = this.Settings.DefaultIndex; index.ThrowIfNullOrEmpty("Cannot infer default index for current connection."); var typeName = this.InferTypeName <T>(); var path = this.CreatePath(index, typeName, "_query"); if (parameters != null && !parameters.Equals(default(DeleteByQueryParameters))) { path = this.AppendDeleteByQueryParametersToPath(path, parameters); } this._deleteToPathAsync(path, query, callback); }
public void DeleteByQueryOverIndicesAsync <T>(string query, IEnumerable <string> indices, IEnumerable <string> types, DeleteByQueryParameters parameters, Action <ConnectionStatus> callback) where T : class { query.ThrowIfNullOrEmpty("query"); if (indices == null || !indices.Any()) { throw new ArgumentNullException("indices"); } if (types == null || !types.Any()) { throw new ArgumentNullException("types"); } var indicesString = string.Join(",", indices.ToArray()); var typesString = string.Join(",", indices.ToArray()); var path = this.CreatePath(indicesString, typesString, "_query"); if (parameters != null && !parameters.Equals(default(DeleteByQueryParameters))) { path = this.AppendDeleteByQueryParametersToPath(path, parameters); } this._deleteToPathAsync(path, query, callback); }
/// <summary> /// Deletes all documents that match the query, without specifying T the return documents is an IEnumerable<dynamic> /// </summary> /// <param name="query">RoutingQueryPathDescriptor also allows you to control which indices and types are affected</param> /// <param name="parameters">Control routing/consistency and replication</param> /// <returns>IDeleteResponse, check .IsValid to validate success</returns> public Task <IDeleteResponse> DeleteByQueryAsync(Func <RoutingQueryPathDescriptor, BaseQuery> query, DeleteByQueryParameters parameters = null) { var descriptor = new RoutingQueryPathDescriptor(); var bq = query(descriptor); var stringQuery = this.Serialize(bq); var path = this.PathResolver.GetDeleteByQueryPathForDynamic(descriptor, "_query"); if (parameters != null) { path = this.PathResolver.AppendDeleteByQueryParametersToPath(path, parameters); } return(this._deleteToPathAsync(path, stringQuery)); }
/// <summary> /// Deletes all documents that match the query /// </summary> /// <param name="query">RoutingQueryPathDescriptor also allows you to control which indices and types are affected</param> /// <param name="parameters">Control routing/consistency and replication</param> /// <returns>IDeleteResponse, check .IsValid to validate success</returns> public IDeleteResponse DeleteByQuery <T>(Func <RoutingQueryPathDescriptor <T>, BaseQuery> query, DeleteByQueryParameters parameters = null) where T : class { var descriptor = new RoutingQueryPathDescriptor <T>(); var bq = query(descriptor); var stringQuery = this.Serialize(bq); var path = this.PathResolver.GetPathForTyped(descriptor, "_query"); if (parameters != null) { path = this.PathResolver.AppendDeleteByQueryParametersToPath(path, parameters); } return(this._deleteToPath(path, stringQuery)); }
public ConnectionStatus DeleteByQueryOverIndices <T>(string query, IEnumerable <string> indices, DeleteByQueryParameters parameters) where T : class { query.ThrowIfNullOrEmpty("query"); if (indices == null || !indices.Any()) { throw new ArgumentNullException("indices"); } var indicesString = string.Join(",", indices.ToArray()); var path = this.CreatePath(indicesString, "_query"); if (parameters != null && !parameters.Equals(default(DeleteByQueryParameters))) { path = this.AppendDeleteByQueryParametersToPath(path, parameters); } return(this._deleteToPath(path, query)); }
/// <summary> /// Deletes all documents that match the query /// </summary> /// <param name="query">RoutingQueryPathDescriptor also allows you to control which indices and types are affected</param> /// <param name="parameters">Control routing/consistency and replication</param> /// <returns>IDeleteResponse, check .IsValid to validate success</returns> public Task <IDeleteResponse> DeleteByQueryAsync <T>(Action <RoutingQueryPathDescriptor <T> > query, DeleteByQueryParameters parameters = null) where T : class { var descriptor = new RoutingQueryPathDescriptor <T>(); query(descriptor); var stringQuery = this.Serialize(descriptor); var path = this.PathResolver.GetPathForTyped(descriptor, "_query"); if (parameters != null) { path = this.PathResolver.AppendDeleteByQueryParametersToPath(path, parameters); } return(this._deleteToPathAsync(path, stringQuery)); }
/// <summary> /// Deletes all documents that match the query, without specifying T the return documents is an IEnumerable<dynamic> /// </summary> /// <param name="query">RoutingQueryPathDescriptor also allows you to control which indices and types are affected</param> /// <param name="parameters">Control routing/consistency and replication</param> /// <returns>IDeleteResponse, check .IsValid to validate success</returns> public IDeleteResponse DeleteByQuery(Action <RoutingQueryPathDescriptor> query, DeleteByQueryParameters parameters = null) { var descriptor = new RoutingQueryPathDescriptor(); query(descriptor); var stringQuery = this.Serialize(descriptor); var path = this.PathResolver.GetPathForDynamic(descriptor, "_query"); if (parameters != null) { path = this.PathResolver.AppendDeleteByQueryParametersToPath(path, parameters); } return(this._deleteToPath(path, stringQuery)); }
/// <summary> /// Deletes all documents that match the query /// </summary> /// <param name="query">QueryPathDescriptor also allows you to control which indices and types are affected</param> /// <param name="parameters">Control routing/consistency and replication</param> /// <returns>ConnectionStatus, check .IsValid to validate success</returns> public Task <ConnectionStatus> DeleteByQueryAsync <T>(Action <QueryPathDescriptor <T> > query, DeleteByQueryParameters parameters = null) where T : class { var descriptor = new QueryPathDescriptor <T>(); query(descriptor); var stringQuery = ElasticClient.Serialize(descriptor); var path = this.GetPathForTyped(descriptor); if (parameters != null) { path = this.AppendDeleteByQueryParametersToPath(path, parameters); } return(this._deleteToPathAsync(path, stringQuery)); }