Skip to content

Add Settings, Aliases and Mappings to RollOverIndexRequest #2969

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Dec 21, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
namespace Nest
{
[JsonConverter(typeof(ReadAsTypeJsonConverter<RolloverIndexRequest>))]
public partial interface IRolloverIndexRequest
public partial interface IRolloverIndexRequest : IIndexState
{
[JsonProperty("conditions")]
IRolloverConditions Conditions { get; set; }
Expand All @@ -17,14 +17,32 @@ public partial interface IRolloverIndexRequest
public partial class RolloverIndexRequest
{
public IRolloverConditions Conditions { get; set; }

public IIndexSettings Settings { get; set; }

public IAliases Aliases { get; set; }

public IMappings Mappings { get; set; }
}

[DescriptorFor("IndicesRollover")]
public partial class RolloverIndexDescriptor
{
IRolloverConditions IRolloverIndexRequest.Conditions { get; set; }
IIndexSettings IIndexState.Settings { get; set; }
IMappings IIndexState.Mappings { get; set; }
IAliases IIndexState.Aliases { get; set; }

public RolloverIndexDescriptor Conditions(Func<RolloverConditionsDescriptor, IRolloverConditions> selector) =>
Assign(a => a.Conditions = selector?.Invoke(new RolloverConditionsDescriptor()));

public RolloverIndexDescriptor Settings(Func<IndexSettingsDescriptor, IPromise<IIndexSettings>> selector) =>
Assign(a => a.Settings = selector?.Invoke(new IndexSettingsDescriptor())?.Value);

public RolloverIndexDescriptor Mappings(Func<MappingsDescriptor, IPromise<IMappings>> selector) =>
Assign(a => a.Mappings = selector?.Invoke(new MappingsDescriptor())?.Value);

public RolloverIndexDescriptor Aliases(Func<AliasesDescriptor, IPromise<IAliases>> selector) =>
Assign(a => a.Aliases = selector?.Invoke(new AliasesDescriptor())?.Value);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
using Tests.Framework;
using Tests.Framework.Integration;
using Tests.Framework.ManagedElasticsearch.Clusters;
using Tests.Framework.MockData;

namespace Tests.Indices.IndexManagement.RolloverIndex
{
Expand Down Expand Up @@ -53,6 +54,36 @@ protected override LazyResponses ClientUsage() => Calls(
{
max_age = "7d",
max_docs = 1000
},
settings = new Dictionary<string, object>
{
{ "index.number_of_shards", 1 },
{ "index.number_of_replicas", 1 }
},
mappings = new
{
doc = new
{
properties = new
{
branches = new
{
type = "text",
fields = new
{
keyword = new
{
type = "keyword",
ignore_above = 256
}
}
}
}
}
},
aliases = new
{
new_projects = new {}
}
};

Expand All @@ -62,6 +93,39 @@ protected override LazyResponses ClientUsage() => Calls(
{
MaxAge = "7d",
MaxDocs = 1000
},
Settings = new Nest.IndexSettings
{
NumberOfShards = 1,
NumberOfReplicas = 1
},
Mappings = new Mappings
{
{ typeof(Project), new TypeMapping
{
Properties = new Properties<Project>
{
{
p => p.Branches, new TextProperty
{
Fields = new Properties
{
{
"keyword", new KeywordProperty
{
IgnoreAbove = 256
}
}
}
}
}
}
}
}
},
Aliases = new Aliases
{
{ "new_projects", new Alias() }
}
};

Expand All @@ -70,6 +134,28 @@ protected override LazyResponses ClientUsage() => Calls(
.Conditions(c => c
.MaxAge("7d")
.MaxDocs(1000)
)
.Settings(s => s
.NumberOfShards(1)
.NumberOfReplicas(1)
)
.Mappings(m => m
.Map<Project>(p => p
.Properties(pp => pp
.Text(t => t
.Name(n => n.Branches)
.Fields(pf => pf
.Keyword(k => k
.Name("keyword")
.IgnoreAbove(256)
)
)
)
)
)
)
.Aliases(a => a
.Alias("new_projects")
);

protected override void ExpectResponse(IRolloverIndexResponse response)
Expand Down