From 7d5e3b4d5333f2d124e4ccd023a88126c9084312 Mon Sep 17 00:00:00 2001 From: Max Horstmann Date: Thu, 20 Jun 2013 15:33:24 -0400 Subject: [PATCH 1/3] Add error handling to GetIndicesPointingToAlias. /wrongname/_aliases used to return an empty array (e.g. in ES 0.20) for a non-existing alias, but in more recent ES versions (0.90) it returns {"error":"IndexMissingException[[wrongname] missing]","status":404} So we need to add explicit error handling here, otherwise GetIndicesPointingToAlias returns two "indices" called "error" and "status". --- src/Nest/ElasticClient-Aliases.cs | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/src/Nest/ElasticClient-Aliases.cs b/src/Nest/ElasticClient-Aliases.cs index 91ed3b046e8..c0dae0e76d1 100644 --- a/src/Nest/ElasticClient-Aliases.cs +++ b/src/Nest/ElasticClient-Aliases.cs @@ -30,18 +30,22 @@ private string _createCommand(string command, AliasParams aliasParam) return cmd; } - /// - /// Get all the indices pointing to an alias - /// - public IEnumerable GetIndicesPointingToAlias(string alias) - { - var path = this.PathResolver.CreateIndexPath(alias, "/_aliases"); - var status = this.Connection.GetSync(path); - var r = this.Deserialize>(status.Result); - return r == null ? Enumerable.Empty() : r.Keys; - } + /// + /// Get all the indices pointing to an alias + /// + public IEnumerable GetIndicesPointingToAlias(string alias) + { + var path = this.PathResolver.CreateIndexPath(alias, "/_aliases"); + var status = this.Connection.GetSync(path); + if (!status.Success) + { + return Enumerable.Empty(); + } + var r = this.Deserialize>(status.Result); + return r == null ? Enumerable.Empty() : r.Keys; + } - /// + /// /// Repoint an alias from a set of old indices to a set of new indices in one operation /// public IIndicesOperationResponse Swap(string alias, IEnumerable oldIndices, IEnumerable newIndices) From a41e4f27401b9fae6ab6cf39965ff81903ede9cb Mon Sep 17 00:00:00 2001 From: Allan hardy Date: Thu, 27 Jun 2013 19:40:49 +1000 Subject: [PATCH 2/3] dont add default port on uris with https scheme --- src/Nest/Extensions/UriExtensions.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Nest/Extensions/UriExtensions.cs b/src/Nest/Extensions/UriExtensions.cs index 239f1ac01be..f9b31c0892b 100644 --- a/src/Nest/Extensions/UriExtensions.cs +++ b/src/Nest/Extensions/UriExtensions.cs @@ -6,7 +6,9 @@ public static class UriExtensions { public static string ToUrlAndOverridePath(this Uri uri, string path) { - return string.Format("http://{0}:{1}{2}", uri.Host, uri.Port, path); + return uri.Scheme == Uri.UriSchemeHttps ? + string.Format("https://{0}{1}", uri.Host, path) : + string.Format("http://{0}:{1}{2}", uri.Host, uri.Port, path); } } } From 4ad6474712b4022591a957aad0a9b388ba7d7fb7 Mon Sep 17 00:00:00 2001 From: Jakob Rasmussen Date: Fri, 28 Jun 2013 16:47:52 +0200 Subject: [PATCH 3/3] Add support to MultiGet to just have ids and indexName as params --- src/Nest/ElasticClient-MultiGet.cs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/Nest/ElasticClient-MultiGet.cs b/src/Nest/ElasticClient-MultiGet.cs index 82a4b1574fd..29142c872f3 100644 --- a/src/Nest/ElasticClient-MultiGet.cs +++ b/src/Nest/ElasticClient-MultiGet.cs @@ -31,6 +31,24 @@ public IEnumerable MultiGet(IEnumerable ids) return this.MultiGet(ids, this.PathResolver.CreateIndexTypePath(index, typeName)); } /// + /// Gets multiple documents of T by id in the specified index + /// + public IEnumerable MultiGet(string index, IEnumerable ids) + where T : class + { + return this.MultiGet(index, ids.Select(i => Convert.ToString(i))); + } + /// + /// Gets multiple documents of T by id in the specified index + /// + public IEnumerable MultiGet(string index, IEnumerable ids) + where T : class + { + var typeName = this.GetTypeNameFor(); + + return this.MultiGet(ids, this.PathResolver.CreateIndexTypePath(index, typeName)); + } + /// /// Gets multiple documents of T by id in the specified index and the specified typename for T /// public IEnumerable MultiGet(string index, string type, IEnumerable ids)