Skip to content
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

Add max_docs to ReindexOnServer API #4071

Merged
merged 2 commits into from
Sep 4, 2019
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
23 changes: 16 additions & 7 deletions src/Nest/Document/Multiple/DeleteByQuery/DeleteByQueryRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ public partial interface IDeleteByQueryRequest
/// </summary>
[DataMember(Name ="slice")]
ISlicedScroll Slice { get; set; }

/// <summary>
/// Limit the number of processed documents
/// </summary>
[DataMember(Name ="max_docs")]
long? MaximumDocuments { get; set; }
}

/// <inheritdoc />
Expand All @@ -34,6 +40,9 @@ public partial class DeleteByQueryRequest

/// <inheritdoc />
public ISlicedScroll Slice { get; set; }

/// <inheritdoc />
public long? MaximumDocuments { get; set; }
}

/// <inheritdoc cref="IDeleteByQueryRequest" />
Expand All @@ -49,24 +58,24 @@ public partial class DeleteByQueryDescriptor<TDocument> : IDeleteByQueryRequest<
{
QueryContainer IDeleteByQueryRequest.Query { get; set; }
ISlicedScroll IDeleteByQueryRequest.Slice { get; set; }
long? IDeleteByQueryRequest.MaximumDocuments { get; set; }

/// <summary>
/// A match_all query to select all documents. Convenient shorthand for specifying
/// a match_all query using <see cref="Query" />
/// </summary>
public DeleteByQueryDescriptor<TDocument> MatchAll() => Assign(new QueryContainerDescriptor<TDocument>().MatchAll(), (a, v) => a.Query = v);

/// <summary>
/// The query to use to select documents for deletion
/// </summary>
/// <inheritdoc cref="IDeleteByQueryRequest.Query"/>
public DeleteByQueryDescriptor<TDocument> Query(Func<QueryContainerDescriptor<TDocument>, QueryContainer> querySelector) =>
Assign(querySelector, (a, v) => a.Query = v?.Invoke(new QueryContainerDescriptor<TDocument>()));

/// <summary>
/// Parallelize the deleting process. This parallelization can improve efficiency and
/// provide a convenient way to break the request down into smaller parts.
/// </summary>
/// <inheritdoc cref="IDeleteByQueryRequest.Slice"/>
public DeleteByQueryDescriptor<TDocument> Slice(Func<SlicedScrollDescriptor<TDocument>, ISlicedScroll> selector) =>
Assign(selector, (a, v) => a.Slice = v?.Invoke(new SlicedScrollDescriptor<TDocument>()));

/// <inheritdoc cref="IDeleteByQueryRequest.MaximumDocuments"/>
public DeleteByQueryDescriptor<TDocument> MaximumDocuments(long? maximumDocuments) =>
Assign(maximumDocuments, (a, v) => a.MaximumDocuments = v);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,17 @@ public partial interface IReindexOnServerRequest
/// <summary>
/// Limit the number of processed documents
/// </summary>
// TODO: Remove in 8.0
[DataMember(Name ="size")]
[Obsolete("Deprecated. Use MaximumDocuments")]
long? Size { get; set; }

/// <summary>
/// Limit the number of processed documents
/// </summary>
[DataMember(Name ="max_docs")]
long? MaximumDocuments { get; set; }

/// <summary>
/// The source for the reindex operation
/// </summary>
Expand All @@ -51,19 +59,23 @@ public partial interface IReindexOnServerRequest
/// <inheritdoc cref="IReindexOnServerRequest" />
public partial class ReindexOnServerRequest
{
/// <inheritdoc cref="IReindexOnServerRequest.Conflicts" />
/// <inheritdoc />
public Conflicts? Conflicts { get; set; }

/// <inheritdoc cref="IReindexOnServerRequest.Destination" />
/// <inheritdoc />
public IReindexDestination Destination { get; set; }

/// <inheritdoc cref="IReindexOnServerRequest.Script" />
/// <inheritdoc />
public IScript Script { get; set; }

/// <inheritdoc cref="IReindexOnServerRequest.Size" />
/// <inheritdoc />
[Obsolete("Deprecated. Use MaximumDocuments")]
public long? Size { get; set; }

/// <inheritdoc cref="IReindexOnServerRequest.Source" />
/// <inheritdoc />
public long? MaximumDocuments { get; set; }

/// <inheritdoc />
public IReindexSource Source { get; set; }
}

Expand All @@ -72,8 +84,10 @@ public partial class ReindexOnServerDescriptor
Conflicts? IReindexOnServerRequest.Conflicts { get; set; }
IReindexDestination IReindexOnServerRequest.Destination { get; set; }
IScript IReindexOnServerRequest.Script { get; set; }
[Obsolete("Deprecated. Use MaximumDocuments")]
long? IReindexOnServerRequest.Size { get; set; }
IReindexSource IReindexOnServerRequest.Source { get; set; }
long? IReindexOnServerRequest.MaximumDocuments { get; set; }

/// <inheritdoc cref="IReindexOnServerRequest.Source" />
public ReindexOnServerDescriptor Source(Func<ReindexSourceDescriptor, IReindexSource> selector = null) =>
Expand All @@ -90,10 +104,15 @@ public ReindexOnServerDescriptor Destination(Func<ReindexDestinationDescriptor,
public ReindexOnServerDescriptor Script(Func<ScriptDescriptor, IScript> scriptSelector) =>
Assign(scriptSelector, (a, v) => a.Script = v?.Invoke(new ScriptDescriptor()));

[Obsolete("Deprecated. Use MaximumDocuments")]
/// <inheritdoc cref="IReindexOnServerRequest.Size" />
public ReindexOnServerDescriptor Size(long? size) => Assign(size, (a, v) => a.Size = v);

/// <inheritdoc cref="IReindexOnServerRequest.Conflicts" />
public ReindexOnServerDescriptor Conflicts(Conflicts? conflicts) => Assign(conflicts, (a, v) => a.Conflicts = v);

/// <inheritdoc cref="IReindexOnServerRequest.MaximumDocuments"/>
public ReindexOnServerDescriptor MaximumDocuments(long? maximumDocuments) =>
Assign(maximumDocuments, (a, v) => a.MaximumDocuments = v);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public interface IReindexSource
IRemoteSource Remote { get; set; }

/// <summary>
/// Limit the number of processed documents
/// The batch size of documents
/// </summary>
[DataMember(Name ="size")]
int? Size { get; set; }
Expand Down
41 changes: 41 additions & 0 deletions src/Nest/Document/Multiple/UpdateByQuery/UpdateByQueryRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,30 @@ namespace Nest
{
public partial interface IUpdateByQueryRequest
{
/// <summary>
/// Parallelize the update process by splitting a query into
/// multiple slices.
/// </summary>
[DataMember(Name ="slice")]
ISlicedScroll Slice { get; set; }

/// <summary>
/// Query to select documents to update
/// </summary>
[DataMember(Name ="query")]
QueryContainer Query { get; set; }

/// <summary>
/// A script specifying the update to make
/// </summary>
[DataMember(Name ="script")]
IScript Script { get; set; }

/// <summary>
/// Limit the number of processed documents
/// </summary>
[DataMember(Name ="max_docs")]
long? MaximumDocuments { get; set; }
}

// ReSharper disable once UnusedMember.Global
Expand All @@ -18,8 +37,14 @@ public partial interface IUpdateByQueryRequest<TDocument> where TDocument : clas

public partial class UpdateByQueryRequest
{
/// <inheritdoc />
public ISlicedScroll Slice { get; set; }
/// <inheritdoc />
public QueryContainer Query { get; set; }
/// <inheritdoc />
public IScript Script { get; set; }
/// <inheritdoc />
public long? MaximumDocuments { get; set; }
}

// ReSharper disable once UnusedTypeParameter
Expand All @@ -32,15 +57,31 @@ public partial class UpdateByQueryDescriptor<TDocument>
{
QueryContainer IUpdateByQueryRequest.Query { get; set; }
IScript IUpdateByQueryRequest.Script { get; set; }
long? IUpdateByQueryRequest.MaximumDocuments { get; set; }
ISlicedScroll IUpdateByQueryRequest.Slice { get; set; }

/// <summary>
/// Query that selects all documents
/// </summary>
public UpdateByQueryDescriptor<TDocument> MatchAll() => Assign(new QueryContainerDescriptor<TDocument>().MatchAll(), (a, v) => a.Query = v);

/// <inheritdoc cref="IUpdateByQueryRequest.Query"/>
public UpdateByQueryDescriptor<TDocument> Query(Func<QueryContainerDescriptor<TDocument>, QueryContainer> querySelector) =>
Assign(querySelector, (a, v) => a.Query = v?.Invoke(new QueryContainerDescriptor<TDocument>()));

/// <inheritdoc cref="IUpdateByQueryRequest.Script"/>
public UpdateByQueryDescriptor<TDocument> Script(string script) => Assign((InlineScript)script, (a, v) => a.Script = v);

/// <inheritdoc cref="IUpdateByQueryRequest.Script"/>
public UpdateByQueryDescriptor<TDocument> Script(Func<ScriptDescriptor, IScript> scriptSelector) =>
Assign(scriptSelector, (a, v) => a.Script = v?.Invoke(new ScriptDescriptor()));

/// <inheritdoc cref="IUpdateByQueryRequest.MaximumDocuments"/>
public UpdateByQueryDescriptor<TDocument> MaximumDocuments(long? maximumDocuments) =>
Assign(maximumDocuments, (a, v) => a.MaximumDocuments = v);

/// <inheritdoc cref="IUpdateByQueryRequest.Slice"/>
public UpdateByQueryDescriptor<TDocument> Slice(Func<SlicedScrollDescriptor<TDocument>, ISlicedScroll> selector) =>
Assign(selector, (a, v) => a.Slice = v?.Invoke(new SlicedScrollDescriptor<TDocument>()));
}
}