From 0a553c9d2277ac9b45bd8d4511fd3e7e7e2749b4 Mon Sep 17 00:00:00 2001 From: Mpdreamz Date: Tue, 12 Apr 2016 18:46:31 +0200 Subject: [PATCH] fix #1980 GetAsync fails when specifying a null index. ```csharp var response = await elasticClient.GetAsync(id, s => s.Index(null)); ``` Would not default index back to inferred type of T. This PR makes specifying null for required route values a noop For optional routevalues null still clears the routevalue so the following still works ```csharp c => c.Index(project, i => i.Id(null)) ``` will reset the id on and send the index request to `/inferredindex/inferredtype` --- .../Domain/CsharpMethod.cs | 8 +- .../Infer/DocumentPath/DocumentPath.cs | 4 +- .../CommonAbstractions/Request/RouteValues.cs | 3 +- src/Nest/_Generated/_Descriptors.generated.cs | 136 +++++++++--------- src/Tests/Document/Single/Get/GetUrlTests.cs | 10 +- src/Tests/tests.yaml | 2 +- 6 files changed, 88 insertions(+), 75 deletions(-) diff --git a/src/CodeGeneration/CodeGeneration.LowLevelClient/Domain/CsharpMethod.cs b/src/CodeGeneration/CodeGeneration.LowLevelClient/Domain/CsharpMethod.cs index 500f539922e..14d6f89aedf 100644 --- a/src/CodeGeneration/CodeGeneration.LowLevelClient/Domain/CsharpMethod.cs +++ b/src/CodeGeneration/CodeGeneration.LowLevelClient/Domain/CsharpMethod.cs @@ -240,16 +240,18 @@ public IEnumerable GetFluentRouteSetters() paramName = paramName.ToLowerInvariant(); var routeValue = paramName; + var routeSetter = p.Required ? "Required" : "Optional"; + if (paramName == "metric") routeValue = "(Metrics)metric"; else if (paramName == "indexMetric") routeValue = "(IndexMetrics)indexMetric"; - var code = $"public {returnType} {p.InterfaceName}({ClrParamType(p.ClrTypeName)} {paramName}) => Assign(a=>a.RouteValues.Optional(\"{p.Name}\", {routeValue}));"; + var code = $"public {returnType} {p.InterfaceName}({ClrParamType(p.ClrTypeName)} {paramName}) => Assign(a=>a.RouteValues.{routeSetter}(\"{p.Name}\", {routeValue}));"; var xmlDoc = $"///{p.Description}"; setters.Add(new FluentRouteSetter { Code = code, XmlDoc = xmlDoc }); if (paramName == "index" || paramName == "type") { code = $"public {returnType} {p.InterfaceName}() where TOther : class "; - code += $"=> Assign(a=>a.RouteValues.Optional(\"{p.Name}\", ({p.ClrTypeName})typeof(TOther)));"; + code += $"=> Assign(a=>a.RouteValues.{routeSetter}(\"{p.Name}\", ({p.ClrTypeName})typeof(TOther)));"; xmlDoc = $"///{p.Description}"; setters.Add(new FluentRouteSetter { Code = code, XmlDoc = xmlDoc }); } @@ -268,7 +270,7 @@ public IEnumerable GetFluentRouteSetters() if (paramName == "fields" && p.Type == "list") { code = $"public {returnType} Fields(params Expression>[] fields) "; - code += "=> Assign(a => a.RouteValues.Optional(\"fields\", (Fields)fields));"; + code += $"=> Assign(a => a.RouteValues.{routeSetter}(\"fields\", (Fields)fields));"; xmlDoc = $"///{p.Description}"; setters.Add(new FluentRouteSetter { Code = code, XmlDoc = xmlDoc }); } diff --git a/src/Nest/CommonAbstractions/Infer/DocumentPath/DocumentPath.cs b/src/Nest/CommonAbstractions/Infer/DocumentPath/DocumentPath.cs index 0bc79c9fb59..1ac8341433e 100644 --- a/src/Nest/CommonAbstractions/Infer/DocumentPath/DocumentPath.cs +++ b/src/Nest/CommonAbstractions/Infer/DocumentPath/DocumentPath.cs @@ -37,13 +37,15 @@ public DocumentPath(Id id) public DocumentPath Index(IndexName index) { + if (index == null) return this; Self.Index = index; return this; } public DocumentPath Type(TypeName type) { + if (type == null) return this; Self.Type = type; return this; } } -} \ No newline at end of file +} diff --git a/src/Nest/CommonAbstractions/Request/RouteValues.cs b/src/Nest/CommonAbstractions/Request/RouteValues.cs index e3b2e07aedd..f5a94284fb7 100644 --- a/src/Nest/CommonAbstractions/Request/RouteValues.cs +++ b/src/Nest/CommonAbstractions/Request/RouteValues.cs @@ -35,12 +35,13 @@ private string GetResolved(string route) private RouteValues Route(string name, IUrlParameter routeValue, bool required = true) { - if (routeValue == null) + if (routeValue == null && !required) { if (this._routeValues.ContainsKey(name)) this._routeValues.Remove(name); return this; } + else if (routeValue == null) return this; this._routeValues[name] = routeValue; return this; diff --git a/src/Nest/_Generated/_Descriptors.generated.cs b/src/Nest/_Generated/_Descriptors.generated.cs index 6cdd857b708..6cdaf386d95 100644 --- a/src/Nest/_Generated/_Descriptors.generated.cs +++ b/src/Nest/_Generated/_Descriptors.generated.cs @@ -977,16 +977,16 @@ public PercolateCountDescriptor(IndexName index, TypeName type) : base(r=>r.Requ partial void DocumentFromPath(TDocument document); ///The index of the document being count percolated. - public PercolateCountDescriptor Index(IndexName index) => Assign(a=>a.RouteValues.Optional("index", index)); + public PercolateCountDescriptor Index(IndexName index) => Assign(a=>a.RouteValues.Required("index", index)); ///The index of the document being count percolated. - public PercolateCountDescriptor Index() where TOther : class => Assign(a=>a.RouteValues.Optional("index", (IndexName)typeof(TOther))); + public PercolateCountDescriptor Index() where TOther : class => Assign(a=>a.RouteValues.Required("index", (IndexName)typeof(TOther))); ///The type of the document being count percolated. - public PercolateCountDescriptor Type(TypeName type) => Assign(a=>a.RouteValues.Optional("type", type)); + public PercolateCountDescriptor Type(TypeName type) => Assign(a=>a.RouteValues.Required("type", type)); ///The type of the document being count percolated. - public PercolateCountDescriptor Type() where TOther : class => Assign(a=>a.RouteValues.Optional("type", (TypeName)typeof(TOther))); + public PercolateCountDescriptor Type() where TOther : class => Assign(a=>a.RouteValues.Required("type", (TypeName)typeof(TOther))); ///Substitute the document in the request body with a document that is known by the specified id. On top of the id, the index and type parameter will be used to retrieve the document from within the cluster. public PercolateCountDescriptor Id(Id id) => Assign(a=>a.RouteValues.Optional("id", id)); @@ -1047,16 +1047,16 @@ public DeleteDescriptor(IndexName index, TypeName type, Id id) : base(r=>r.Requi partial void DocumentFromPath(T document); ///The name of the index - public DeleteDescriptor Index(IndexName index) => Assign(a=>a.RouteValues.Optional("index", index)); + public DeleteDescriptor Index(IndexName index) => Assign(a=>a.RouteValues.Required("index", index)); ///The name of the index - public DeleteDescriptor Index() where TOther : class => Assign(a=>a.RouteValues.Optional("index", (IndexName)typeof(TOther))); + public DeleteDescriptor Index() where TOther : class => Assign(a=>a.RouteValues.Required("index", (IndexName)typeof(TOther))); ///The type of the document - public DeleteDescriptor Type(TypeName type) => Assign(a=>a.RouteValues.Optional("type", type)); + public DeleteDescriptor Type(TypeName type) => Assign(a=>a.RouteValues.Required("type", type)); ///The type of the document - public DeleteDescriptor Type() where TOther : class => Assign(a=>a.RouteValues.Optional("type", (TypeName)typeof(TOther))); + public DeleteDescriptor Type() where TOther : class => Assign(a=>a.RouteValues.Required("type", (TypeName)typeof(TOther))); ///Specific write consistency setting for the operation @@ -1158,16 +1158,16 @@ public DocumentExistsDescriptor(IndexName index, TypeName type, Id id) : base(r= partial void DocumentFromPath(T document); ///The name of the index - public DocumentExistsDescriptor Index(IndexName index) => Assign(a=>a.RouteValues.Optional("index", index)); + public DocumentExistsDescriptor Index(IndexName index) => Assign(a=>a.RouteValues.Required("index", index)); ///The name of the index - public DocumentExistsDescriptor Index() where TOther : class => Assign(a=>a.RouteValues.Optional("index", (IndexName)typeof(TOther))); + public DocumentExistsDescriptor Index() where TOther : class => Assign(a=>a.RouteValues.Required("index", (IndexName)typeof(TOther))); ///The type of the document (use `_all` to fetch the first document matching the ID across all types) - public DocumentExistsDescriptor Type(TypeName type) => Assign(a=>a.RouteValues.Optional("type", type)); + public DocumentExistsDescriptor Type(TypeName type) => Assign(a=>a.RouteValues.Required("type", type)); ///The type of the document (use `_all` to fetch the first document matching the ID across all types) - public DocumentExistsDescriptor Type() where TOther : class => Assign(a=>a.RouteValues.Optional("type", (TypeName)typeof(TOther))); + public DocumentExistsDescriptor Type() where TOther : class => Assign(a=>a.RouteValues.Required("type", (TypeName)typeof(TOther))); ///The ID of the parent document @@ -1213,16 +1213,16 @@ public ExplainDescriptor(IndexName index, TypeName type, Id id) : base(r=>r.Requ partial void DocumentFromPath(TDocument document); ///The name of the index - public ExplainDescriptor Index(IndexName index) => Assign(a=>a.RouteValues.Optional("index", index)); + public ExplainDescriptor Index(IndexName index) => Assign(a=>a.RouteValues.Required("index", index)); ///The name of the index - public ExplainDescriptor Index() where TOther : class => Assign(a=>a.RouteValues.Optional("index", (IndexName)typeof(TOther))); + public ExplainDescriptor Index() where TOther : class => Assign(a=>a.RouteValues.Required("index", (IndexName)typeof(TOther))); ///The type of the document - public ExplainDescriptor Type(TypeName type) => Assign(a=>a.RouteValues.Optional("type", type)); + public ExplainDescriptor Type(TypeName type) => Assign(a=>a.RouteValues.Required("type", type)); ///The type of the document - public ExplainDescriptor Type() where TOther : class => Assign(a=>a.RouteValues.Optional("type", (TypeName)typeof(TOther))); + public ExplainDescriptor Type() where TOther : class => Assign(a=>a.RouteValues.Required("type", (TypeName)typeof(TOther))); ///Specify whether wildcards and prefix queries in the query string query should be analyzed (default: false) @@ -1345,16 +1345,16 @@ public GetDescriptor(IndexName index, TypeName type, Id id) : base(r=>r.Required partial void DocumentFromPath(T document); ///The name of the index - public GetDescriptor Index(IndexName index) => Assign(a=>a.RouteValues.Optional("index", index)); + public GetDescriptor Index(IndexName index) => Assign(a=>a.RouteValues.Required("index", index)); ///The name of the index - public GetDescriptor Index() where TOther : class => Assign(a=>a.RouteValues.Optional("index", (IndexName)typeof(TOther))); + public GetDescriptor Index() where TOther : class => Assign(a=>a.RouteValues.Required("index", (IndexName)typeof(TOther))); ///The type of the document (use `_all` to fetch the first document matching the ID across all types) - public GetDescriptor Type(TypeName type) => Assign(a=>a.RouteValues.Optional("type", type)); + public GetDescriptor Type(TypeName type) => Assign(a=>a.RouteValues.Required("type", type)); ///The type of the document (use `_all` to fetch the first document matching the ID across all types) - public GetDescriptor Type() where TOther : class => Assign(a=>a.RouteValues.Optional("type", (TypeName)typeof(TOther))); + public GetDescriptor Type() where TOther : class => Assign(a=>a.RouteValues.Required("type", (TypeName)typeof(TOther))); ///A comma-separated list of fields to return in the response @@ -1456,16 +1456,16 @@ public SourceDescriptor(IndexName index, TypeName type, Id id) : base(r=>r.Requi partial void DocumentFromPath(T document); ///The name of the index - public SourceDescriptor Index(IndexName index) => Assign(a=>a.RouteValues.Optional("index", index)); + public SourceDescriptor Index(IndexName index) => Assign(a=>a.RouteValues.Required("index", index)); ///The name of the index - public SourceDescriptor Index() where TOther : class => Assign(a=>a.RouteValues.Optional("index", (IndexName)typeof(TOther))); + public SourceDescriptor Index() where TOther : class => Assign(a=>a.RouteValues.Required("index", (IndexName)typeof(TOther))); ///The type of the document; use `_all` to fetch the first document matching the ID across all types - public SourceDescriptor Type(TypeName type) => Assign(a=>a.RouteValues.Optional("type", type)); + public SourceDescriptor Type(TypeName type) => Assign(a=>a.RouteValues.Required("type", type)); ///The type of the document; use `_all` to fetch the first document matching the ID across all types - public SourceDescriptor Type() where TOther : class => Assign(a=>a.RouteValues.Optional("type", (TypeName)typeof(TOther))); + public SourceDescriptor Type() where TOther : class => Assign(a=>a.RouteValues.Required("type", (TypeName)typeof(TOther))); ///The ID of the parent document @@ -1560,16 +1560,16 @@ public IndexDescriptor(IndexName index, TypeName type) : base(r=>r.Required("ind public IndexDescriptor Id(Id id) => Assign(a=>a.RouteValues.Optional("id", id)); ///The name of the index - public IndexDescriptor Index(IndexName index) => Assign(a=>a.RouteValues.Optional("index", index)); + public IndexDescriptor Index(IndexName index) => Assign(a=>a.RouteValues.Required("index", index)); ///The name of the index - public IndexDescriptor Index() where TOther : class => Assign(a=>a.RouteValues.Optional("index", (IndexName)typeof(TOther))); + public IndexDescriptor Index() where TOther : class => Assign(a=>a.RouteValues.Required("index", (IndexName)typeof(TOther))); ///The type of the document - public IndexDescriptor Type(TypeName type) => Assign(a=>a.RouteValues.Optional("type", type)); + public IndexDescriptor Type(TypeName type) => Assign(a=>a.RouteValues.Required("type", type)); ///The type of the document - public IndexDescriptor Type() where TOther : class => Assign(a=>a.RouteValues.Optional("type", (TypeName)typeof(TOther))); + public IndexDescriptor Type() where TOther : class => Assign(a=>a.RouteValues.Required("type", (TypeName)typeof(TOther))); ///Explicit write consistency setting for the operation @@ -1731,10 +1731,10 @@ public CloseIndexDescriptor(Indices index) : base(r=>r.Required("index", index)) ///A comma separated list of indices to close - public CloseIndexDescriptor Index(Indices index) => Assign(a=>a.RouteValues.Optional("index", index)); + public CloseIndexDescriptor Index(Indices index) => Assign(a=>a.RouteValues.Required("index", index)); ///A comma separated list of indices to close - public CloseIndexDescriptor Index() where TOther : class => Assign(a=>a.RouteValues.Optional("index", (Indices)typeof(TOther))); + public CloseIndexDescriptor Index() where TOther : class => Assign(a=>a.RouteValues.Required("index", (Indices)typeof(TOther))); ///A comma separated list of indices to close public CloseIndexDescriptor AllIndices() => this.Index(Indices.All); @@ -1773,10 +1773,10 @@ public CreateIndexDescriptor(IndexName index) : base(r=>r.Required("index", inde ///The name of the index - public CreateIndexDescriptor Index(IndexName index) => Assign(a=>a.RouteValues.Optional("index", index)); + public CreateIndexDescriptor Index(IndexName index) => Assign(a=>a.RouteValues.Required("index", index)); ///The name of the index - public CreateIndexDescriptor Index() where TOther : class => Assign(a=>a.RouteValues.Optional("index", (IndexName)typeof(TOther))); + public CreateIndexDescriptor Index() where TOther : class => Assign(a=>a.RouteValues.Required("index", (IndexName)typeof(TOther))); ///Explicit operation timeout @@ -1806,10 +1806,10 @@ public DeleteIndexDescriptor(Indices index) : base(r=>r.Required("index", index) ///A comma-separated list of indices to delete; use `_all` or `*` string to delete all indices - public DeleteIndexDescriptor Index(Indices index) => Assign(a=>a.RouteValues.Optional("index", index)); + public DeleteIndexDescriptor Index(Indices index) => Assign(a=>a.RouteValues.Required("index", index)); ///A comma-separated list of indices to delete; use `_all` or `*` string to delete all indices - public DeleteIndexDescriptor Index() where TOther : class => Assign(a=>a.RouteValues.Optional("index", (Indices)typeof(TOther))); + public DeleteIndexDescriptor Index() where TOther : class => Assign(a=>a.RouteValues.Required("index", (Indices)typeof(TOther))); ///A comma-separated list of indices to delete; use `_all` or `*` string to delete all indices public DeleteIndexDescriptor AllIndices() => this.Index(Indices.All); @@ -1841,10 +1841,10 @@ public DeleteAliasDescriptor(Indices index, Names name) : base(r=>r.Required("in ///A comma-separated list of index names (supports wildcards); use `_all` for all indices - public DeleteAliasDescriptor Index(Indices index) => Assign(a=>a.RouteValues.Optional("index", index)); + public DeleteAliasDescriptor Index(Indices index) => Assign(a=>a.RouteValues.Required("index", index)); ///A comma-separated list of index names (supports wildcards); use `_all` for all indices - public DeleteAliasDescriptor Index() where TOther : class => Assign(a=>a.RouteValues.Optional("index", (Indices)typeof(TOther))); + public DeleteAliasDescriptor Index() where TOther : class => Assign(a=>a.RouteValues.Required("index", (Indices)typeof(TOther))); ///A comma-separated list of index names (supports wildcards); use `_all` for all indices public DeleteAliasDescriptor AllIndices() => this.Index(Indices.All); @@ -1900,10 +1900,10 @@ public DeleteWarmerDescriptor(Indices index, Names name) : base(r=>r.Required("i ///A comma-separated list of index names to delete warmers from (supports wildcards); use `_all` to perform the operation on all indices. - public DeleteWarmerDescriptor Index(Indices index) => Assign(a=>a.RouteValues.Optional("index", index)); + public DeleteWarmerDescriptor Index(Indices index) => Assign(a=>a.RouteValues.Required("index", index)); ///A comma-separated list of index names to delete warmers from (supports wildcards); use `_all` to perform the operation on all indices. - public DeleteWarmerDescriptor Index() where TOther : class => Assign(a=>a.RouteValues.Optional("index", (Indices)typeof(TOther))); + public DeleteWarmerDescriptor Index() where TOther : class => Assign(a=>a.RouteValues.Required("index", (Indices)typeof(TOther))); ///A comma-separated list of index names to delete warmers from (supports wildcards); use `_all` to perform the operation on all indices. public DeleteWarmerDescriptor AllIndices() => this.Index(Indices.All); @@ -1930,10 +1930,10 @@ public IndexExistsDescriptor(Indices index) : base(r=>r.Required("index", index) ///A comma-separated list of indices to check - public IndexExistsDescriptor Index(Indices index) => Assign(a=>a.RouteValues.Optional("index", index)); + public IndexExistsDescriptor Index(Indices index) => Assign(a=>a.RouteValues.Required("index", index)); ///A comma-separated list of indices to check - public IndexExistsDescriptor Index() where TOther : class => Assign(a=>a.RouteValues.Optional("index", (Indices)typeof(TOther))); + public IndexExistsDescriptor Index() where TOther : class => Assign(a=>a.RouteValues.Required("index", (Indices)typeof(TOther))); ///A comma-separated list of indices to check public IndexExistsDescriptor AllIndices() => this.Index(Indices.All); @@ -2037,19 +2037,19 @@ public TypeExistsDescriptor(Indices index, Types type) : base(r=>r.Required("ind ///A comma-separated list of index names; use `_all` to check the types across all indices - public TypeExistsDescriptor Index(Indices index) => Assign(a=>a.RouteValues.Optional("index", index)); + public TypeExistsDescriptor Index(Indices index) => Assign(a=>a.RouteValues.Required("index", index)); ///A comma-separated list of index names; use `_all` to check the types across all indices - public TypeExistsDescriptor Index() where TOther : class => Assign(a=>a.RouteValues.Optional("index", (Indices)typeof(TOther))); + public TypeExistsDescriptor Index() where TOther : class => Assign(a=>a.RouteValues.Required("index", (Indices)typeof(TOther))); ///A comma-separated list of index names; use `_all` to check the types across all indices public TypeExistsDescriptor AllIndices() => this.Index(Indices.All); ///A comma-separated list of document types to check - public TypeExistsDescriptor Type(Types type) => Assign(a=>a.RouteValues.Optional("type", type)); + public TypeExistsDescriptor Type(Types type) => Assign(a=>a.RouteValues.Required("type", type)); ///A comma-separated list of document types to check - public TypeExistsDescriptor Type() where TOther : class => Assign(a=>a.RouteValues.Optional("type", (Types)typeof(TOther))); + public TypeExistsDescriptor Type() where TOther : class => Assign(a=>a.RouteValues.Required("type", (Types)typeof(TOther))); ///A comma-separated list of document types to check public TypeExistsDescriptor AllTypes() => this.Type(Types.All); @@ -2212,10 +2212,10 @@ public GetIndexDescriptor(Indices index) : base(r=>r.Required("index", index)){} ///A comma-separated list of index names - public GetIndexDescriptor Index(Indices index) => Assign(a=>a.RouteValues.Optional("index", index)); + public GetIndexDescriptor Index(Indices index) => Assign(a=>a.RouteValues.Required("index", index)); ///A comma-separated list of index names - public GetIndexDescriptor Index() where TOther : class => Assign(a=>a.RouteValues.Optional("index", (Indices)typeof(TOther))); + public GetIndexDescriptor Index() where TOther : class => Assign(a=>a.RouteValues.Required("index", (Indices)typeof(TOther))); ///A comma-separated list of index names public GetIndexDescriptor AllIndices() => this.Index(Indices.All); @@ -2606,10 +2606,10 @@ public OpenIndexDescriptor(Indices index) : base(r=>r.Required("index", index)){ ///A comma separated list of indices to open - public OpenIndexDescriptor Index(Indices index) => Assign(a=>a.RouteValues.Optional("index", index)); + public OpenIndexDescriptor Index(Indices index) => Assign(a=>a.RouteValues.Required("index", index)); ///A comma separated list of indices to open - public OpenIndexDescriptor Index() where TOther : class => Assign(a=>a.RouteValues.Optional("index", (Indices)typeof(TOther))); + public OpenIndexDescriptor Index() where TOther : class => Assign(a=>a.RouteValues.Required("index", (Indices)typeof(TOther))); ///A comma separated list of indices to open public OpenIndexDescriptor AllIndices() => this.Index(Indices.All); @@ -2700,10 +2700,10 @@ public PutAliasDescriptor(Indices index, Name name) : base(r=>r.Required("index" ///A comma-separated list of index names the alias should point to (supports wildcards); use `_all` to perform the operation on all indices. - public PutAliasDescriptor Index(Indices index) => Assign(a=>a.RouteValues.Optional("index", index)); + public PutAliasDescriptor Index(Indices index) => Assign(a=>a.RouteValues.Required("index", index)); ///A comma-separated list of index names the alias should point to (supports wildcards); use `_all` to perform the operation on all indices. - public PutAliasDescriptor Index() where TOther : class => Assign(a=>a.RouteValues.Optional("index", (Indices)typeof(TOther))); + public PutAliasDescriptor Index() where TOther : class => Assign(a=>a.RouteValues.Required("index", (Indices)typeof(TOther))); ///A comma-separated list of index names the alias should point to (supports wildcards); use `_all` to perform the operation on all indices. public PutAliasDescriptor AllIndices() => this.Index(Indices.All); @@ -2743,10 +2743,10 @@ public PutMappingDescriptor(TypeName type) : base(r=>r.Required("type", type)){} public PutMappingDescriptor AllIndices() => this.Index(Indices.All); ///The name of the document type - public PutMappingDescriptor Type(TypeName type) => Assign(a=>a.RouteValues.Optional("type", type)); + public PutMappingDescriptor Type(TypeName type) => Assign(a=>a.RouteValues.Required("type", type)); ///The name of the document type - public PutMappingDescriptor Type() where TOther : class => Assign(a=>a.RouteValues.Optional("type", (TypeName)typeof(TOther))); + public PutMappingDescriptor Type() where TOther : class => Assign(a=>a.RouteValues.Required("type", (TypeName)typeof(TOther))); ///Explicit operation timeout @@ -3631,16 +3631,16 @@ public PercolateDescriptor(IndexName index, TypeName type) : base(r=>r.Required( partial void DocumentFromPath(TDocument document); ///The index of the document being percolated. - public PercolateDescriptor Index(IndexName index) => Assign(a=>a.RouteValues.Optional("index", index)); + public PercolateDescriptor Index(IndexName index) => Assign(a=>a.RouteValues.Required("index", index)); ///The index of the document being percolated. - public PercolateDescriptor Index() where TOther : class => Assign(a=>a.RouteValues.Optional("index", (IndexName)typeof(TOther))); + public PercolateDescriptor Index() where TOther : class => Assign(a=>a.RouteValues.Required("index", (IndexName)typeof(TOther))); ///The type of the document being percolated. - public PercolateDescriptor Type(TypeName type) => Assign(a=>a.RouteValues.Optional("type", type)); + public PercolateDescriptor Type(TypeName type) => Assign(a=>a.RouteValues.Required("type", type)); ///The type of the document being percolated. - public PercolateDescriptor Type() where TOther : class => Assign(a=>a.RouteValues.Optional("type", (TypeName)typeof(TOther))); + public PercolateDescriptor Type() where TOther : class => Assign(a=>a.RouteValues.Required("type", (TypeName)typeof(TOther))); ///Substitute the document in the request body with a document that is known by the specified id. On top of the id, the index and type parameter will be used to retrieve the document from within the cluster. public PercolateDescriptor Id(Id id) => Assign(a=>a.RouteValues.Optional("id", id)); @@ -4451,16 +4451,16 @@ public TermVectorsDescriptor(IndexName index, TypeName type) : base(r=>r.Require partial void DocumentFromPath(TDocument document); ///The index in which the document resides. - public TermVectorsDescriptor Index(IndexName index) => Assign(a=>a.RouteValues.Optional("index", index)); + public TermVectorsDescriptor Index(IndexName index) => Assign(a=>a.RouteValues.Required("index", index)); ///The index in which the document resides. - public TermVectorsDescriptor Index() where TOther : class => Assign(a=>a.RouteValues.Optional("index", (IndexName)typeof(TOther))); + public TermVectorsDescriptor Index() where TOther : class => Assign(a=>a.RouteValues.Required("index", (IndexName)typeof(TOther))); ///The type of the document. - public TermVectorsDescriptor Type(TypeName type) => Assign(a=>a.RouteValues.Optional("type", type)); + public TermVectorsDescriptor Type(TypeName type) => Assign(a=>a.RouteValues.Required("type", type)); ///The type of the document. - public TermVectorsDescriptor Type() where TOther : class => Assign(a=>a.RouteValues.Optional("type", (TypeName)typeof(TOther))); + public TermVectorsDescriptor Type() where TOther : class => Assign(a=>a.RouteValues.Required("type", (TypeName)typeof(TOther))); ///The id of the document, when not specified a doc param should be supplied. public TermVectorsDescriptor Id(Id id) => Assign(a=>a.RouteValues.Optional("id", id)); @@ -4537,16 +4537,16 @@ public UpdateDescriptor(IndexName index, TypeName type, Id id) : base(r=>r.Requi partial void DocumentFromPath(TDocument document); ///The name of the index - public UpdateDescriptor Index(IndexName index) => Assign(a=>a.RouteValues.Optional("index", index)); + public UpdateDescriptor Index(IndexName index) => Assign(a=>a.RouteValues.Required("index", index)); ///The name of the index - public UpdateDescriptor Index() where TOther : class => Assign(a=>a.RouteValues.Optional("index", (IndexName)typeof(TOther))); + public UpdateDescriptor Index() where TOther : class => Assign(a=>a.RouteValues.Required("index", (IndexName)typeof(TOther))); ///The type of the document - public UpdateDescriptor Type(TypeName type) => Assign(a=>a.RouteValues.Optional("type", type)); + public UpdateDescriptor Type(TypeName type) => Assign(a=>a.RouteValues.Required("type", type)); ///The type of the document - public UpdateDescriptor Type() where TOther : class => Assign(a=>a.RouteValues.Optional("type", (TypeName)typeof(TOther))); + public UpdateDescriptor Type() where TOther : class => Assign(a=>a.RouteValues.Required("type", (TypeName)typeof(TOther))); ///Explicit write consistency setting for the operation @@ -4610,10 +4610,10 @@ public UpdateByQueryDescriptor(Indices index) : base(r=>r.Required("index", inde ///A comma-separated list of index names to search; use `_all` or empty string to perform the operation on all indices - public UpdateByQueryDescriptor Index(Indices index) => Assign(a=>a.RouteValues.Optional("index", index)); + public UpdateByQueryDescriptor Index(Indices index) => Assign(a=>a.RouteValues.Required("index", index)); ///A comma-separated list of index names to search; use `_all` or empty string to perform the operation on all indices - public UpdateByQueryDescriptor Index() where TOther : class => Assign(a=>a.RouteValues.Optional("index", (Indices)typeof(TOther))); + public UpdateByQueryDescriptor Index() where TOther : class => Assign(a=>a.RouteValues.Required("index", (Indices)typeof(TOther))); ///A comma-separated list of index names to search; use `_all` or empty string to perform the operation on all indices public UpdateByQueryDescriptor AllIndices() => this.Index(Indices.All); @@ -4787,10 +4787,10 @@ public DeleteByQueryDescriptor(Indices index) : base(r=>r.Required("index", inde ///A comma-separated list of indices to restrict the operation; use `_all` to perform the operation on all indices - public DeleteByQueryDescriptor Index(Indices index) => Assign(a=>a.RouteValues.Optional("index", index)); + public DeleteByQueryDescriptor Index(Indices index) => Assign(a=>a.RouteValues.Required("index", index)); ///A comma-separated list of indices to restrict the operation; use `_all` to perform the operation on all indices - public DeleteByQueryDescriptor Index() where TOther : class => Assign(a=>a.RouteValues.Optional("index", (Indices)typeof(TOther))); + public DeleteByQueryDescriptor Index() where TOther : class => Assign(a=>a.RouteValues.Required("index", (Indices)typeof(TOther))); ///A comma-separated list of indices to restrict the operation; use `_all` to perform the operation on all indices public DeleteByQueryDescriptor AllIndices() => this.Index(Indices.All); diff --git a/src/Tests/Document/Single/Get/GetUrlTests.cs b/src/Tests/Document/Single/Get/GetUrlTests.cs index e5b065444ff..75a44a46ef2 100644 --- a/src/Tests/Document/Single/Get/GetUrlTests.cs +++ b/src/Tests/Document/Single/Get/GetUrlTests.cs @@ -19,7 +19,15 @@ await GET("/project/project/1") .FluentAsync(c => c.GetAsync(1)) .RequestAsync(c => c.GetAsync(new GetRequest(1))) ; - + + //new GetRequest(null, null, 1) is still an error + await GET("/project/project/1") + .Fluent(c => c.Get(1, g => g.Index(null).Type(null))) + .Request(c => c.Get(new GetRequest(new DocumentPath(1).Index(null).Type(null)))) + .FluentAsync(c => c.GetAsync(1, g => g.Index(null).Type(null))) + .RequestAsync(c => c.GetAsync(new GetRequest(new DocumentPath(1).Index(null).Type(null)))) + ; + await GET("/testindex/typeindex/1") .Fluent(c => c.Get(1, g => g.Index("testindex").Type("typeindex"))) .Request(c => c.Get(new GetRequest(new DocumentPath(1).Index("testindex").Type("typeindex")))) diff --git a/src/Tests/tests.yaml b/src/Tests/tests.yaml index bb8ea0f52a5..bed985ced67 100644 --- a/src/Tests/tests.yaml +++ b/src/Tests/tests.yaml @@ -1,5 +1,5 @@ # mode either u (unit test), i (integration test) or m (mixed mode) -mode: m +mode: u # the elasticsearch version that should be started elasticsearch_version: 2.3.0 # whether we want to forcefully reseed on the node, if you are starting the tests with a node already running