Skip to content

Commit fc374f7

Browse files
committed
fix #601 CreateIndex(string, func) no longer the odd man out of the bunch being the only one that takes a string as first arg
Conflicts: src/Nest/DSL/CreateIndexDescriptor.cs src/Nest/ElasticClient-CreateIndex.cs
1 parent 3b43b02 commit fc374f7

File tree

3 files changed

+11
-9
lines changed

3 files changed

+11
-9
lines changed

src/Nest/DSL/CreateIndexDescriptor.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
using System.Linq;
44
using System.Text;
55
using Elasticsearch.Net;
6+
using Elasticsearch.Net.Connection;
67
using Newtonsoft.Json;
78
using System.Linq.Expressions;
89
using Nest.Resolvers;
@@ -18,6 +19,11 @@ public partial class CreateIndexDescriptor : IndexPathDescriptorBase<CreateIndex
1819
private IConnectionSettingsValues _connectionSettings;
1920

2021

22+
public CreateIndexDescriptor(IConnectionSettingsValues connectionSettings)
23+
{
24+
this._connectionSettings = connectionSettings;
25+
}
26+
2127
/// <summary>
2228
/// Initialize the descriptor using the values from for instance a previous Get Index Settings call.
2329
/// </summary>
@@ -27,12 +33,6 @@ public CreateIndexDescriptor InitializeUsing(IndexSettings indexSettings)
2733
return this;
2834
}
2935

30-
internal CreateIndexDescriptor SetConnectionSettings(IConnectionSettingsValues connectionSettings)
31-
{
32-
this._connectionSettings = connectionSettings;
33-
return this;
34-
}
35-
3636
/// <summary>
3737
/// Set the number of shards (if possible) for the new index.
3838
/// </summary>

src/Nest/DSL/Paths/IndexPathDescriptor.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ namespace Nest
1919
/// index is not optional
2020
/// </summary>
2121
public class IndexPathDescriptorBase<TDescriptor, TParameters> : BasePathDescriptor<TDescriptor>
22-
where TDescriptor : IndexPathDescriptorBase<TDescriptor, TParameters>, new()
22+
where TDescriptor : IndexPathDescriptorBase<TDescriptor, TParameters>
2323
where TParameters : FluentRequestParameters<TParameters>, new()
2424
{
2525
internal IndexNameMarker _Index { get; set; }

src/Nest/ElasticClient-CreateIndex.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,20 @@ public partial class ElasticClient
1111
/// <inheritdoc />
1212
public IIndicesOperationResponse CreateIndex(Func<CreateIndexDescriptor, CreateIndexDescriptor> createIndexSelector)
1313
{
14+
var descriptor = createIndexSelector(new CreateIndexDescriptor(this._connectionSettings));
1415
return this.Dispatch<CreateIndexDescriptor, CreateIndexRequestParameters, IndicesOperationResponse>(
15-
c => createIndexSelector(new CreateIndexDescriptor().SetConnectionSettings(this._connectionSettings)),
16+
descriptor,
1617
(p, d) => this.RawDispatch.IndicesCreateDispatch<IndicesOperationResponse>(p, d._IndexSettings)
1718
);
1819
}
1920

2021
/// <inheritdoc />
2122
public Task<IIndicesOperationResponse> CreateIndexAsync(Func<CreateIndexDescriptor, CreateIndexDescriptor> createIndexSelector)
2223
{
24+
var descriptor = createIndexSelector(new CreateIndexDescriptor(this._connectionSettings));
2325
return this.DispatchAsync
2426
<CreateIndexDescriptor, CreateIndexRequestParameters, IndicesOperationResponse, IIndicesOperationResponse>(
25-
c => createIndexSelector(new CreateIndexDescriptor().SetConnectionSettings(this._connectionSettings)),
27+
descriptor,
2628
(p, d) => this.RawDispatch.IndicesCreateDispatchAsync<IndicesOperationResponse>(p, d._IndexSettings)
2729
);
2830
}

0 commit comments

Comments
 (0)