Skip to content

track_total_hits should be Union of boolean and integer #43954

Closed
@russcam

Description

@russcam

Issue

The search.json REST API spec in 7.x defines track_total_hits as a boolean

"track_total_hits": {
"type" : "boolean",
"description": "Indicate if the number of documents that match the query should be tracked"
},

The documentation indicates however that track_total_hits can be a boolean or an integer i.e. a discriminated union of two different types.

Since Elasticsearch clients generate code from the REST API specs, track_total_hits will be modelled as a boolean only. For example

in elasticsearch-js

https://github.com/elastic/elasticsearch-js/blob/21863965706e0ebfcbe34e0436bf3359579dc834/api/requestParams.d.ts#L1123

in elasticsearch-net

https://github.com/elastic/elasticsearch-net/blob/69cf48c400bfc774ed16aeb502abd13565d72f3c/src/Nest/Requests.NoNamespace.cs#L2812-L2817

Request

track_total_hits should be modelled as a union of boolean and int. For example,

 "track_total_hits": { 
   "type" : "boolean|integer", 
   "description": "Indicate if the number of documents that match the query should be tracked (true or false), or an integer to accurately track the total hit count that match the query up to" 
 },

I propose making this change for 8.x. It would not be feasible to make this change in 7.x because it would break (binary) compatibility of already released, generated client code.

Metadata

Metadata

Assignees

No one assigned

    Labels

    :Search/SearchSearch-related issues that do not fall into other categoriesTeam:SearchMeta label for search team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions