public UpdateResponse Update(Action <UpdateDescriptor <dynamic> > updateSelector) { var updateDescriptor = new UpdateDescriptor <dynamic>(); updateSelector(updateDescriptor); var data = ElasticClient.Serialize(updateDescriptor); var path = this.CreateUpdatePath <dynamic>(updateDescriptor); return(this._Update(path, data)); }
public IUpdateResponse Update <T>(Action <UpdateDescriptor <T> > updateSelector) where T : class { var updateDescriptor = new UpdateDescriptor <T>(); updateSelector(updateDescriptor); var data = JsonConvert.SerializeObject(updateDescriptor, Formatting.Indented, IndexSerializationSettings); //var data = ElasticClient.Serialize(updateDescriptor); var path = this.CreateUpdatePath <T>(updateDescriptor); return(this._Update(path, data)); }
private string CreateUpdatePath <T, K>(UpdateDescriptor <T, K> s) where T : class where K : class { var index = s._Index ?? this.IndexNameResolver.GetIndexForType <T>(); var type = s._Type != null?s._Type.Resolve(this.Settings) : this.GetTypeNameFor <T>(); var id = s._Id ?? this.IdResolver.GetIdFor(s._Object); index.ThrowIfNullOrEmpty("index"); type.ThrowIfNullOrEmpty("type"); id.ThrowIfNullOrEmpty("id"); var path = this.PathResolver.CreateIndexTypeIdPath(index, type, id, "_update") + "/?"; if (s._Consistency.HasValue) { path += "consistency=" + Enum.GetName(typeof(Consistency), s._Consistency.Value); } if (s._Replication.HasValue) { path += "replication=" + Enum.GetName(typeof(Replication), s._Replication.Value); } if (s._Refresh.HasValue) { path += "refresh=" + s._Refresh.Value.ToString().ToLower(); } if (s._Timeout.HasValue) { path += "timeout=" + s._Timeout.ToString(); } if (s._Timeout.HasValue) { path += "timeout=" + s._Timeout.ToString(); } if (!string.IsNullOrWhiteSpace(s._Percolate)) { path += "percolate=" + s._Percolate; } if (!string.IsNullOrWhiteSpace(s._Parent)) { path += "parent=" + s._Parent; } if (!string.IsNullOrWhiteSpace(s._Routing)) { path += "routing=" + s._Routing; } return(path); }
private string CreateUpdatePath <T, K>(UpdateDescriptor <T, K> s) where T : class where K : class { var index = s._Index ?? this.Infer.IndexName <T>(); var type = s._Type != null?s._Type.Resolve(this._connectionSettings) : this.Infer.TypeName <T>(); var id = s._Id ?? this.Infer.Id(s._Object); index.ThrowIfNullOrEmpty("index"); type.ThrowIfNullOrEmpty("type"); id.ThrowIfNullOrEmpty("id"); var querystringPairs = new List <string>(); if (s._Consistency.HasValue) { querystringPairs.Add("consistency=" + Enum.GetName(typeof(Consistency), s._Consistency.Value)); } if (s._Replication.HasValue) { querystringPairs.Add("replication=" + Enum.GetName(typeof(Replication), s._Replication.Value)); } if (s._Refresh.HasValue) { querystringPairs.Add("refresh=" + s._Refresh.Value.ToString().ToLower()); } if (s._Timeout.HasValue) { querystringPairs.Add("timeout=" + s._Timeout); } if (!string.IsNullOrWhiteSpace(s._Percolate)) { querystringPairs.Add("percolate=" + s._Percolate); } if (!string.IsNullOrWhiteSpace(s._Parent)) { querystringPairs.Add("parent=" + s._Parent); } if (!string.IsNullOrWhiteSpace(s._Routing)) { querystringPairs.Add("routing=" + s._Routing); } if (s._RetriesOnConflict.HasValue) { querystringPairs.Add("retries_on_conflict=" + s._RetriesOnConflict); } return(this.PathResolver.CreateIndexTypeIdPath(index, type, id, "_update") + "/?" + string.Join("&", querystringPairs)); }