Skip to content

Commit

Permalink
Skip max_docs query string params (#4075)
Browse files Browse the repository at this point in the history
This commit skips max_docs as query string params on DeleteByQuery,UpdateByQuery and ReindexOnServer.
The parameter can also be defined in the request body, so prefer this.
  • Loading branch information
russcam authored Sep 5, 2019
1 parent ea2fb30 commit 9914ccd
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 48 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
using System.Collections.Generic;

namespace ApiGenerator.Configuration.Overrides.Endpoints
{
public class DeleteByQueryOverrides : EndpointOverridesBase
{
public override IEnumerable<string> SkipQueryStringParams => new[] { "max_docs", };
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
using System.Collections.Generic;

namespace ApiGenerator.Configuration.Overrides.Endpoints
{
public class ReindexOnServerOverrides : EndpointOverridesBase
{
public override IEnumerable<string> SkipQueryStringParams => new[] { "max_docs", };
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
using System.Collections.Generic;

namespace ApiGenerator.Configuration.Overrides.Endpoints
{
public class UpdateByQueryOverrides : EndpointOverridesBase
{
public override IEnumerable<string> SkipQueryStringParams => new[] { "max_docs", };
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -417,13 +417,6 @@ public bool? Lenient
set => Q("lenient", value);
}

///<summary>Maximum number of documents to process (default: all documents)</summary>
public long? MaxDocs
{
get => Q<long? >("max_docs");
set => Q("max_docs", value);
}

///<summary>Specify the node or shard the operation should be performed on (default: random)</summary>
public string Preference
{
Expand Down Expand Up @@ -1422,13 +1415,6 @@ public TimeSpan Timeout
public class ReindexOnServerRequestParameters : RequestParameters<ReindexOnServerRequestParameters>
{
public override HttpMethod DefaultHttpMethod => HttpMethod.POST;
///<summary>Maximum number of documents to process (default: all documents)</summary>
public long? MaxDocs
{
get => Q<long? >("max_docs");
set => Q("max_docs", value);
}

///<summary>Should the effected indexes be refreshed?</summary>
public bool? Refresh
{
Expand Down Expand Up @@ -2131,13 +2117,6 @@ public bool? Lenient
set => Q("lenient", value);
}

///<summary>Maximum number of documents to process (default: all documents)</summary>
public long? MaxDocs
{
get => Q<long? >("max_docs");
set => Q("max_docs", value);
}

///<summary>Ingest pipeline to set on index requests made by this action. (default: none)</summary>
public string Pipeline
{
Expand Down
6 changes: 0 additions & 6 deletions src/Nest/Descriptors.NoNamespace.cs
Original file line number Diff line number Diff line change
Expand Up @@ -316,8 +316,6 @@ public DeleteByQueryDescriptor<TDocument> Index<TOther>()
public DeleteByQueryDescriptor<TDocument> IgnoreUnavailable(bool? ignoreunavailable = true) => Qs("ignore_unavailable", ignoreunavailable);
///<summary>Specify whether format-based query failures (such as providing text to a numeric field) should be ignored</summary>
public DeleteByQueryDescriptor<TDocument> Lenient(bool? lenient = true) => Qs("lenient", lenient);
///<summary>Maximum number of documents to process (default: all documents)</summary>
public DeleteByQueryDescriptor<TDocument> MaxDocs(long? maxdocs) => Qs("max_docs", maxdocs);
///<summary>Specify the node or shard the operation should be performed on (default: random)</summary>
public DeleteByQueryDescriptor<TDocument> Preference(string preference) => Qs("preference", preference);
///<summary>Query in the Lucene query string syntax</summary>
Expand Down Expand Up @@ -1140,8 +1138,6 @@ public partial class ReindexOnServerDescriptor : RequestDescriptorBase<ReindexOn
internal override ApiUrls ApiUrls => ApiUrlsLookups.NoNamespaceReindexOnServer;
// values part of the url path
// Request parameters
///<summary>Maximum number of documents to process (default: all documents)</summary>
public ReindexOnServerDescriptor MaxDocs(long? maxdocs) => Qs("max_docs", maxdocs);
///<summary>Should the effected indexes be refreshed?</summary>
public ReindexOnServerDescriptor Refresh(bool? refresh = true) => Qs("refresh", refresh);
///<summary>The throttle to set on this request in sub-requests per second. -1 means no throttle.</summary>
Expand Down Expand Up @@ -1596,8 +1592,6 @@ public UpdateByQueryDescriptor<TDocument> Index<TOther>()
public UpdateByQueryDescriptor<TDocument> IgnoreUnavailable(bool? ignoreunavailable = true) => Qs("ignore_unavailable", ignoreunavailable);
///<summary>Specify whether format-based query failures (such as providing text to a numeric field) should be ignored</summary>
public UpdateByQueryDescriptor<TDocument> Lenient(bool? lenient = true) => Qs("lenient", lenient);
///<summary>Maximum number of documents to process (default: all documents)</summary>
public UpdateByQueryDescriptor<TDocument> MaxDocs(long? maxdocs) => Qs("max_docs", maxdocs);
///<summary>Ingest pipeline to set on index requests made by this action. (default: none)</summary>
public UpdateByQueryDescriptor<TDocument> Pipeline(string pipeline) => Qs("pipeline", pipeline);
///<summary>Specify the node or shard the operation should be performed on (default: random)</summary>
Expand Down
21 changes: 0 additions & 21 deletions src/Nest/Requests.NoNamespace.cs
Original file line number Diff line number Diff line change
Expand Up @@ -674,13 +674,6 @@ public bool? Lenient
set => Q("lenient", value);
}

///<summary>Maximum number of documents to process (default: all documents)</summary>
public long? MaxDocs
{
get => Q<long? >("max_docs");
set => Q("max_docs", value);
}

///<summary>Specify the node or shard the operation should be performed on (default: random)</summary>
public string Preference
{
Expand Down Expand Up @@ -2413,13 +2406,6 @@ public partial class ReindexOnServerRequest : PlainRequestBase<ReindexOnServerRe
internal override ApiUrls ApiUrls => ApiUrlsLookups.NoNamespaceReindexOnServer;
// values part of the url path
// Request parameters
///<summary>Maximum number of documents to process (default: all documents)</summary>
public long? MaxDocs
{
get => Q<long? >("max_docs");
set => Q("max_docs", value);
}

///<summary>Should the effected indexes be refreshed?</summary>
public bool? Refresh
{
Expand Down Expand Up @@ -3471,13 +3457,6 @@ public bool? Lenient
set => Q("lenient", value);
}

///<summary>Maximum number of documents to process (default: all documents)</summary>
public long? MaxDocs
{
get => Q<long? >("max_docs");
set => Q("max_docs", value);
}

///<summary>Ingest pipeline to set on index requests made by this action. (default: none)</summary>
public string Pipeline
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public DeleteByQueryApiTests(IntrusiveOperationCluster cluster, EndpointUsage us

protected override object ExpectJson { get; } = new
{
max_docs = Project.Projects.Count,
query = new
{
ids = new
Expand All @@ -38,6 +39,7 @@ public DeleteByQueryApiTests(IntrusiveOperationCluster cluster, EndpointUsage us
protected override Func<DeleteByQueryDescriptor<Project>, IDeleteByQueryRequest> Fluent => d => d
.Index(Indices)
.IgnoreUnavailable()
.MaximumDocuments(Project.Projects.Count)
.Query(q => q
.Ids(ids => ids
.Values(Project.First.Name, "x")
Expand All @@ -49,6 +51,7 @@ public DeleteByQueryApiTests(IntrusiveOperationCluster cluster, EndpointUsage us
protected override DeleteByQueryRequest Initializer => new DeleteByQueryRequest(Indices)
{
IgnoreUnavailable = true,
MaximumDocuments = Project.Projects.Count,
Query = new IdsQuery
{
Values = new Id[] { Project.First.Name, "x" }
Expand Down

0 comments on commit 9914ccd

Please sign in to comment.