Skip to content

[8.17] [Search] Fix content Indices documents error on paginate (#219471)#219626

Merged
saarikabhasi merged 1 commit intoelastic:8.17from
saarikabhasi:backport/8.17/pr-219471
Apr 30, 2025
Merged

[8.17] [Search] Fix content Indices documents error on paginate (#219471)#219626
saarikabhasi merged 1 commit intoelastic:8.17from
saarikabhasi:backport/8.17/pr-219471

Conversation

@saarikabhasi
Copy link
Copy Markdown
Member

Backport

This will backport the following commits from main to 8.17:

Questions ?

Please refer to the Backport tool documentation

)

Initially added fix in `8.17` branch in
[PR](elastic#219411), but need this
change in `main`, `8.18`, `8.19` & `9.0.0` and the file's paths are
different in all versions(main, 8.18/8.19, 8.17, 9.0.0).

Created this new PR, adding fix in `main` & will try to backport to
other versions.

## Summary
When `track_total_hits` is not provided to `fetchSearchResults`, the
value is set to `false`. As a result, the `search` api does not include
total hit count in its response. Thus, the total count of hit is 0 and
onPaginate results in error. This PR sets `track_total_hits` as an
optional argument in `fetchSearchResults`

**Note**
One other option would be to set `track_total_hits` to true but, based
on this
[documentation](https://www.elastic.co/docs/solutions/search/the-search-api#track-total-hits)
setting `track_total_hits` to true would affect query performance.

```
Setting track_total_hits to true will cause Elasticsearch to return exact hit counts, which could hurt query performance because it disables the [Max WAND](https://www.elastic.co/blog/faster-retrieval-of-top-hits-in-elasticsearch-with-block-max-wand) optimization.

````

https://github.com/user-attachments/assets/4284e88f-2614-4fbe-a0eb-1980355f5bff

### Checklist

- [x] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios

(cherry picked from commit 69d7124)
@saarikabhasi saarikabhasi added the backport This PR is a backport of another PR label Apr 29, 2025
@saarikabhasi saarikabhasi enabled auto-merge (squash) April 29, 2025 19:13
@saarikabhasi
Copy link
Copy Markdown
Member Author

/ci

@saarikabhasi saarikabhasi merged commit c4d9620 into elastic:8.17 Apr 30, 2025
11 checks passed
@elasticmachine
Copy link
Copy Markdown
Contributor

💚 Build Succeeded

Metrics [docs]

✅ unchanged

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport This PR is a backport of another PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants