Skip to content

Commit

Permalink
Merge branch 'master' of github.com:Mpdreamz/NEST
Browse files Browse the repository at this point in the history
  • Loading branch information
Mpdreamz committed Jul 4, 2013
2 parents 6bbab2f + af72fb1 commit aa6185e
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 12 deletions.
26 changes: 15 additions & 11 deletions src/Nest/ElasticClient-Aliases.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,22 @@ private string _createCommand(string command, AliasParams aliasParam)
return cmd;
}

/// <summary>
/// Get all the indices pointing to an alias
/// </summary>
public IEnumerable<string> GetIndicesPointingToAlias(string alias)
{
var path = this.PathResolver.CreateIndexPath(alias, "/_aliases");
var status = this.Connection.GetSync(path);
var r = this.Deserialize<Dictionary<string, object>>(status.Result);
return r == null ? Enumerable.Empty<string>() : r.Keys;
}
/// <summary>
/// Get all the indices pointing to an alias
/// </summary>
public IEnumerable<string> GetIndicesPointingToAlias(string alias)
{
var path = this.PathResolver.CreateIndexPath(alias, "/_aliases");
var status = this.Connection.GetSync(path);
if (!status.Success)
{
return Enumerable.Empty<string>();
}
var r = this.Deserialize<Dictionary<string, object>>(status.Result);
return r == null ? Enumerable.Empty<string>() : r.Keys;
}

/// <summary>
/// <summary>
/// Repoint an alias from a set of old indices to a set of new indices in one operation
/// </summary>
public IIndicesOperationResponse Swap(string alias, IEnumerable<string> oldIndices, IEnumerable<string> newIndices)
Expand Down
18 changes: 18 additions & 0 deletions src/Nest/ElasticClient-MultiGet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,24 @@ public IEnumerable<T> MultiGet<T>(IEnumerable<string> ids)
return this.MultiGet<T>(ids, this.PathResolver.CreateIndexTypePath(index, typeName));
}
/// <summary>
/// Gets multiple documents of T by id in the specified index
/// </summary>
public IEnumerable<T> MultiGet<T>(string index, IEnumerable<int> ids)
where T : class
{
return this.MultiGet<T>(index, ids.Select(i => Convert.ToString(i)));
}
/// <summary>
/// Gets multiple documents of T by id in the specified index
/// </summary>
public IEnumerable<T> MultiGet<T>(string index, IEnumerable<string> ids)
where T : class
{
var typeName = this.GetTypeNameFor<T>();

return this.MultiGet<T>(ids, this.PathResolver.CreateIndexTypePath(index, typeName));
}
/// <summary>
/// Gets multiple documents of T by id in the specified index and the specified typename for T
/// </summary>
public IEnumerable<T> MultiGet<T>(string index, string type, IEnumerable<int> ids)
Expand Down
4 changes: 3 additions & 1 deletion src/Nest/Extensions/UriExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}

0 comments on commit aa6185e

Please sign in to comment.