Skip to content

Commit b8dd09b

Browse files
committed
Add track_total_hits to search request body (#3917)
This commit removes track_total_hits as a query string parameter on a search request and instead defines it in the body, allowing track_total_hits to work with individual search requests in multi search API. Closes #3906 (cherry picked from commit 75317ec)
1 parent 6d29d6d commit b8dd09b

File tree

8 files changed

+171
-119
lines changed

8 files changed

+171
-119
lines changed

src/CodeGeneration/ApiGenerator/Configuration/Overrides/GlobalOverrides.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ public class GlobalOverrides : EndpointOverridesBase
4040
"copy_settings", //this still needs a PR?
4141
"source", // allows the body to be specified as a request param, we do not want to advertise this with a strongly typed method
4242
"timestamp",
43-
"_source_include", "_source_exclude" // can be removed once https://github.com/elastic/elasticsearch/pull/41439 is in
43+
"_source_include", "_source_exclude", // can be removed once https://github.com/elastic/elasticsearch/pull/41439 is in
44+
"track_total_hits"
4445
};
4546
}
4647
}

src/Elasticsearch.Net/Api/RequestParameters/RequestParameters.NoNamespace.cs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1712,13 +1712,6 @@ public bool? TotalHitsAsInteger
17121712
set => Q("rest_total_hits_as_int", value);
17131713
}
17141714

1715-
///<summary>Indicate if the number of documents that match the query should be tracked</summary>
1716-
public bool? TrackTotalHits
1717-
{
1718-
get => Q<bool? >("track_total_hits");
1719-
set => Q("track_total_hits", value);
1720-
}
1721-
17221715
///<summary>Specify whether aggregation and suggester names should be prefixed by their respective types in the response</summary>
17231716
public bool? TypedKeys
17241717
{

src/Nest/Descriptors.NoNamespace.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1300,8 +1300,6 @@ public SearchDescriptor<TInferDocument> Index<TOther>()
13001300
public SearchDescriptor<TInferDocument> SuggestText(string suggesttext) => Qs("suggest_text", suggesttext);
13011301
///<summary>Indicates whether hits.total should be rendered as an integer or an object in the rest search response</summary>
13021302
public SearchDescriptor<TInferDocument> TotalHitsAsInteger(bool? totalhitsasinteger = true) => Qs("rest_total_hits_as_int", totalhitsasinteger);
1303-
///<summary>Indicate if the number of documents that match the query should be tracked</summary>
1304-
public SearchDescriptor<TInferDocument> TrackTotalHits(bool? tracktotalhits = true) => Qs("track_total_hits", tracktotalhits);
13051303
///<summary>Specify whether aggregation and suggester names should be prefixed by their respective types in the response</summary>
13061304
public SearchDescriptor<TInferDocument> TypedKeys(bool? typedkeys = true) => Qs("typed_keys", typedkeys);
13071305
}

src/Nest/Requests.NoNamespace.cs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2809,13 +2809,6 @@ public bool? TotalHitsAsInteger
28092809
set => Q("rest_total_hits_as_int", value);
28102810
}
28112811

2812-
///<summary>Indicate if the number of documents that match the query should be tracked</summary>
2813-
public bool? TrackTotalHits
2814-
{
2815-
get => Q<bool? >("track_total_hits");
2816-
set => Q("track_total_hits", value);
2817-
}
2818-
28192812
///<summary>Specify whether aggregation and suggester names should be prefixed by their respective types in the response</summary>
28202813
public bool? TypedKeys
28212814
{

src/Nest/Search/MultiSearch/MultiSearchJsonConverter.cs renamed to src/Nest/Search/MultiSearch/MultiSearchFormatter.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
namespace Nest
66
{
7-
internal class MultiSearchJsonConverter : IJsonFormatter<IMultiSearchRequest>
7+
internal class MultiSearchFormatter : IJsonFormatter<IMultiSearchRequest>
88
{
99
private const byte Newline = (byte)'\n';
1010

src/Nest/Search/MultiSearch/MultiSearchRequest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
namespace Nest
77
{
88
[MapsApi("msearch.json")]
9-
[JsonFormatter(typeof(MultiSearchJsonConverter))]
9+
[JsonFormatter(typeof(MultiSearchFormatter))]
1010
public partial interface IMultiSearchRequest
1111
{
1212
IDictionary<string, ISearchRequest> Operations { get; set; }

0 commit comments

Comments
 (0)