Skip to content

Commit 3f4dbaa

Browse files
committed
Merge pull request #1593 from robertlyson/CatAliasesApiIssue
Fix for CatAliases API #1591
2 parents 8811e82 + 8ff89b2 commit 3f4dbaa

File tree

4 files changed

+69
-2
lines changed

4 files changed

+69
-2
lines changed

Diff for: src/Nest/DSL/PutAliasDescriptor.cs

+20
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ public interface IPutAliasRequest : IIndexOptionalNamePath<PutAliasRequestParame
1414
{
1515
[JsonProperty("routing")]
1616
string Routing { get; set; }
17+
[JsonProperty("search_routing")]
18+
string SearchRouting { get; set; }
19+
[JsonProperty("index_routing")]
20+
string IndexRouting { get; set; }
1721

1822
[JsonProperty("filter")]
1923
[JsonConverter(typeof(CompositeJsonConverter<ReadAsTypeConverter<FilterContainer>, CustomJsonConverter>))]
@@ -35,6 +39,8 @@ public PutAliasRequest(string name) : base(name) { }
3539
public PutAliasRequest(string index, string name) : base(index, name) { }
3640

3741
public string Routing { get; set; }
42+
public string SearchRouting { get; set; }
43+
public string IndexRouting { get; set; }
3844

3945
public IFilterContainer Filter { get; set; }
4046

@@ -51,6 +57,8 @@ public partial class PutAliasDescriptor
5157
{
5258
IPutAliasRequest Self { get { return this; } }
5359
string IPutAliasRequest.Routing { get; set; }
60+
string IPutAliasRequest.SearchRouting { get; set; }
61+
string IPutAliasRequest.IndexRouting { get; set; }
5462
IFilterContainer IPutAliasRequest.Filter { get; set; }
5563

5664
public PutAliasDescriptor Routing(string routing)
@@ -59,6 +67,18 @@ public PutAliasDescriptor Routing(string routing)
5967
return this;
6068
}
6169

70+
public PutAliasDescriptor SearchRouting(string searchRouting)
71+
{
72+
Self.SearchRouting = searchRouting;
73+
return this;
74+
}
75+
76+
public PutAliasDescriptor IndexRouting(string indexRouting)
77+
{
78+
Self.IndexRouting = indexRouting;
79+
return this;
80+
}
81+
6282
public PutAliasDescriptor Filter<T>(Func<FilterDescriptor<T>, FilterContainer> filterSelector)
6383
where T : class
6484
{

Diff for: src/Nest/Domain/Cat/CatAliasesRecord.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ public class CatAliasesRecord : ICatRecord
1414
[JsonProperty("filter")]
1515
public string Filter { get; set; }
1616

17-
[JsonProperty("indexRouting")]
17+
[JsonProperty("routing.index")]
1818
public string IndexRouting { get; set; }
1919

20-
[JsonProperty("searchRouting")]
20+
[JsonProperty("routing.search")]
2121
public string SearchRouting { get; set; }
2222
}
2323
}

Diff for: src/Tests/Nest.Tests.Integration/Nest.Tests.Integration.csproj

+1
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,7 @@
182182
<Compile Include="Reproduce\Reproduce1457Tests.cs" />
183183
<Compile Include="Reproduce\Reproduce1474Tests.cs" />
184184
<Compile Include="Reproduce\Reproduce1515Tests.cs" />
185+
<Compile Include="Reproduce\Reproduce1591Tests.cs" />
185186
<Compile Include="Reproduce\Reproduce769Tests.cs" />
186187
<Compile Include="Reproduce\Reproduce945Tests.cs" />
187188
<Compile Include="Reproduce\Reproduce953Tests.cs" />
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
using System;
2+
using System.Linq;
3+
using FluentAssertions;
4+
using NUnit.Framework;
5+
6+
namespace Nest.Tests.Integration.Reproduce
7+
{
8+
[TestFixture]
9+
public class Reproduce1591Tests : IntegrationTests
10+
{
11+
private readonly string _aliasName = Guid.NewGuid().ToString();
12+
private readonly string _indexName = Guid.NewGuid().ToString();
13+
14+
[SetUp]
15+
public void SetUp()
16+
{
17+
Client.CreateIndex(_indexName);
18+
}
19+
20+
[TearDown]
21+
public void Teardown()
22+
{
23+
Client.DeleteIndex(_indexName);
24+
}
25+
26+
[Test]
27+
public void Test()
28+
{
29+
var putAliasResponse = Client.PutAlias(d => d
30+
.Index(_indexName)
31+
.Name(_aliasName)
32+
.IndexRouting("indexrouting")
33+
.SearchRouting("searchrouting"));
34+
35+
putAliasResponse.IsValid.Should().BeTrue();
36+
37+
var catResponse = Client.CatAliases(d => d.V()).Records
38+
.FirstOrDefault(x => x.Index == _indexName);
39+
40+
catResponse.Should().NotBeNull();
41+
catResponse.Alias.Should().Be(_aliasName);
42+
catResponse.IndexRouting.Should().Be("indexrouting");
43+
catResponse.SearchRouting.Should().Be("searchrouting");
44+
}
45+
}
46+
}

0 commit comments

Comments
 (0)