Skip to content

[Search] Fix content Indices documents error on paginate#219471

Merged
saarikabhasi merged 1 commit intoelastic:mainfrom
saarikabhasi:fix/ent-search-index-details-pagination
Apr 29, 2025
Merged

[Search] Fix content Indices documents error on paginate#219471
saarikabhasi merged 1 commit intoelastic:mainfrom
saarikabhasi:fix/ent-search-index-details-pagination

Conversation

@saarikabhasi
Copy link
Copy Markdown
Member

@saarikabhasi saarikabhasi commented Apr 28, 2025

Initially added fix in 8.17 branch in PR, 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 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.

demo.mov

Checklist

@saarikabhasi saarikabhasi added release_note:skip Skip the PR/issue when compiling release notes v8.17.0 v8.18.0 v8.19.0 labels Apr 28, 2025
@saarikabhasi saarikabhasi requested a review from a team as a code owner April 28, 2025 23:02
@elasticmachine
Copy link
Copy Markdown
Contributor

💚 Build Succeeded

Metrics [docs]

✅ unchanged

@TattdCodeMonkey TattdCodeMonkey added the backport:version Backport to applied version labels label Apr 29, 2025
@saarikabhasi saarikabhasi merged commit 69d7124 into elastic:main Apr 29, 2025
26 checks passed
@kibanamachine
Copy link
Copy Markdown
Contributor

Starting backport for target branches: 8.17, 8.18, 8.19, 9.0

https://github.com/elastic/kibana/actions/runs/14735078383

kibanamachine pushed a commit to kibanamachine/kibana that referenced this pull request Apr 29, 2025
)

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)
kibanamachine pushed a commit to kibanamachine/kibana that referenced this pull request Apr 29, 2025
)

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)
kibanamachine pushed a commit to kibanamachine/kibana that referenced this pull request Apr 29, 2025
)

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)
@kibanamachine
Copy link
Copy Markdown
Contributor

💔 Some backports could not be created

Status Branch Result
8.17 Cherrypick failed because the selected commit (69d7124) is empty. Did you already backport this commit?
8.18
8.19
9.0

Note: Successful backport PRs will be merged automatically after passing CI.

Manual backport

To create the backport manually run:

node scripts/backport --pr 219471

Questions ?

Please refer to the Backport tool documentation

kibanamachine added a commit that referenced this pull request Apr 29, 2025
) (#219578)

# Backport

This will backport the following commits from `main` to `8.19`:
- [[Search] Fix content Indices documents error on paginate
(#219471)](#219471)

<!--- Backport version: 9.6.6 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sorenlouv/backport)

<!--BACKPORT [{"author":{"name":"Saarika
Bhasi","email":"55930906+saarikabhasi@users.noreply.github.com"},"sourceCommit":{"committedDate":"2025-04-29T15:24:07Z","message":"[Search]
Fix content Indices documents error on paginate (#219471)\n\nInitially
added fix in `8.17` branch
in\n[PR](#219411), but need
this\nchange in `main`, `8.18`, `8.19` & `9.0.0` and the file's paths
are\ndifferent in all versions(main, 8.18/8.19, 8.17, 9.0.0).\n\nCreated
this new PR, adding fix in `main` & will try to backport to\nother
versions.\n\n## Summary\nWhen `track_total_hits` is not provided to
`fetchSearchResults`, the\nvalue is set to `false`. As a result, the
`search` api does not include\ntotal hit count in its response. Thus,
the total count of hit is 0 and\nonPaginate results in error. This PR
sets `track_total_hits` as an\noptional argument in
`fetchSearchResults`\n\n**Note**\nOne other option would be to set
`track_total_hits` to true but, based\non
this\n[documentation](https://www.elastic.co/docs/solutions/search/the-search-api#track-total-hits)\nsetting
`track_total_hits` to true would affect query
performance.\n\n```\nSetting 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.\n\n````\n\n\n\nhttps://github.com/user-attachments/assets/4284e88f-2614-4fbe-a0eb-1980355f5bff\n\n\n\n\n###
Checklist\n\n- [x] [Unit or
functional\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\nwere
updated or added to match the most common
scenarios","sha":"69d71244d67c7659590aa04f04cea5dd06e2d290","branchLabelMapping":{"^v9.1.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","v9.0.0","Team:Search","backport:version","v8.17.0","v8.18.0","v9.1.0","v8.19.0"],"title":"[Search]
Fix content Indices documents error on
paginate","number":219471,"url":"https://github.com/elastic/kibana/pull/219471","mergeCommit":{"message":"[Search]
Fix content Indices documents error on paginate (#219471)\n\nInitially
added fix in `8.17` branch
in\n[PR](#219411), but need
this\nchange in `main`, `8.18`, `8.19` & `9.0.0` and the file's paths
are\ndifferent in all versions(main, 8.18/8.19, 8.17, 9.0.0).\n\nCreated
this new PR, adding fix in `main` & will try to backport to\nother
versions.\n\n## Summary\nWhen `track_total_hits` is not provided to
`fetchSearchResults`, the\nvalue is set to `false`. As a result, the
`search` api does not include\ntotal hit count in its response. Thus,
the total count of hit is 0 and\nonPaginate results in error. This PR
sets `track_total_hits` as an\noptional argument in
`fetchSearchResults`\n\n**Note**\nOne other option would be to set
`track_total_hits` to true but, based\non
this\n[documentation](https://www.elastic.co/docs/solutions/search/the-search-api#track-total-hits)\nsetting
`track_total_hits` to true would affect query
performance.\n\n```\nSetting 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.\n\n````\n\n\n\nhttps://github.com/user-attachments/assets/4284e88f-2614-4fbe-a0eb-1980355f5bff\n\n\n\n\n###
Checklist\n\n- [x] [Unit or
functional\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\nwere
updated or added to match the most common
scenarios","sha":"69d71244d67c7659590aa04f04cea5dd06e2d290"}},"sourceBranch":"main","suggestedTargetBranches":["9.0","8.17","8.18","8.19"],"targetPullRequestStates":[{"branch":"9.0","label":"v9.0.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"8.17","label":"v8.17.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"8.18","label":"v8.18.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v9.1.0","branchLabelMappingKey":"^v9.1.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/219471","number":219471,"mergeCommit":{"message":"[Search]
Fix content Indices documents error on paginate (#219471)\n\nInitially
added fix in `8.17` branch
in\n[PR](#219411), but need
this\nchange in `main`, `8.18`, `8.19` & `9.0.0` and the file's paths
are\ndifferent in all versions(main, 8.18/8.19, 8.17, 9.0.0).\n\nCreated
this new PR, adding fix in `main` & will try to backport to\nother
versions.\n\n## Summary\nWhen `track_total_hits` is not provided to
`fetchSearchResults`, the\nvalue is set to `false`. As a result, the
`search` api does not include\ntotal hit count in its response. Thus,
the total count of hit is 0 and\nonPaginate results in error. This PR
sets `track_total_hits` as an\noptional argument in
`fetchSearchResults`\n\n**Note**\nOne other option would be to set
`track_total_hits` to true but, based\non
this\n[documentation](https://www.elastic.co/docs/solutions/search/the-search-api#track-total-hits)\nsetting
`track_total_hits` to true would affect query
performance.\n\n```\nSetting 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.\n\n````\n\n\n\nhttps://github.com/user-attachments/assets/4284e88f-2614-4fbe-a0eb-1980355f5bff\n\n\n\n\n###
Checklist\n\n- [x] [Unit or
functional\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\nwere
updated or added to match the most common
scenarios","sha":"69d71244d67c7659590aa04f04cea5dd06e2d290"}},{"branch":"8.19","label":"v8.19.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->

Co-authored-by: Saarika Bhasi <55930906+saarikabhasi@users.noreply.github.com>
kibanamachine added a commit that referenced this pull request Apr 29, 2025
…) (#219579)

# Backport

This will backport the following commits from `main` to `9.0`:
- [[Search] Fix content Indices documents error on paginate
(#219471)](#219471)

<!--- Backport version: 9.6.6 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sorenlouv/backport)

<!--BACKPORT [{"author":{"name":"Saarika
Bhasi","email":"55930906+saarikabhasi@users.noreply.github.com"},"sourceCommit":{"committedDate":"2025-04-29T15:24:07Z","message":"[Search]
Fix content Indices documents error on paginate (#219471)\n\nInitially
added fix in `8.17` branch
in\n[PR](#219411), but need
this\nchange in `main`, `8.18`, `8.19` & `9.0.0` and the file's paths
are\ndifferent in all versions(main, 8.18/8.19, 8.17, 9.0.0).\n\nCreated
this new PR, adding fix in `main` & will try to backport to\nother
versions.\n\n## Summary\nWhen `track_total_hits` is not provided to
`fetchSearchResults`, the\nvalue is set to `false`. As a result, the
`search` api does not include\ntotal hit count in its response. Thus,
the total count of hit is 0 and\nonPaginate results in error. This PR
sets `track_total_hits` as an\noptional argument in
`fetchSearchResults`\n\n**Note**\nOne other option would be to set
`track_total_hits` to true but, based\non
this\n[documentation](https://www.elastic.co/docs/solutions/search/the-search-api#track-total-hits)\nsetting
`track_total_hits` to true would affect query
performance.\n\n```\nSetting 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.\n\n````\n\n\n\nhttps://github.com/user-attachments/assets/4284e88f-2614-4fbe-a0eb-1980355f5bff\n\n\n\n\n###
Checklist\n\n- [x] [Unit or
functional\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\nwere
updated or added to match the most common
scenarios","sha":"69d71244d67c7659590aa04f04cea5dd06e2d290","branchLabelMapping":{"^v9.1.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","v9.0.0","Team:Search","backport:version","v8.17.0","v8.18.0","v9.1.0","v8.19.0"],"title":"[Search]
Fix content Indices documents error on
paginate","number":219471,"url":"https://github.com/elastic/kibana/pull/219471","mergeCommit":{"message":"[Search]
Fix content Indices documents error on paginate (#219471)\n\nInitially
added fix in `8.17` branch
in\n[PR](#219411), but need
this\nchange in `main`, `8.18`, `8.19` & `9.0.0` and the file's paths
are\ndifferent in all versions(main, 8.18/8.19, 8.17, 9.0.0).\n\nCreated
this new PR, adding fix in `main` & will try to backport to\nother
versions.\n\n## Summary\nWhen `track_total_hits` is not provided to
`fetchSearchResults`, the\nvalue is set to `false`. As a result, the
`search` api does not include\ntotal hit count in its response. Thus,
the total count of hit is 0 and\nonPaginate results in error. This PR
sets `track_total_hits` as an\noptional argument in
`fetchSearchResults`\n\n**Note**\nOne other option would be to set
`track_total_hits` to true but, based\non
this\n[documentation](https://www.elastic.co/docs/solutions/search/the-search-api#track-total-hits)\nsetting
`track_total_hits` to true would affect query
performance.\n\n```\nSetting 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.\n\n````\n\n\n\nhttps://github.com/user-attachments/assets/4284e88f-2614-4fbe-a0eb-1980355f5bff\n\n\n\n\n###
Checklist\n\n- [x] [Unit or
functional\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\nwere
updated or added to match the most common
scenarios","sha":"69d71244d67c7659590aa04f04cea5dd06e2d290"}},"sourceBranch":"main","suggestedTargetBranches":["9.0","8.17","8.18","8.19"],"targetPullRequestStates":[{"branch":"9.0","label":"v9.0.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"8.17","label":"v8.17.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"8.18","label":"v8.18.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v9.1.0","branchLabelMappingKey":"^v9.1.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/219471","number":219471,"mergeCommit":{"message":"[Search]
Fix content Indices documents error on paginate (#219471)\n\nInitially
added fix in `8.17` branch
in\n[PR](#219411), but need
this\nchange in `main`, `8.18`, `8.19` & `9.0.0` and the file's paths
are\ndifferent in all versions(main, 8.18/8.19, 8.17, 9.0.0).\n\nCreated
this new PR, adding fix in `main` & will try to backport to\nother
versions.\n\n## Summary\nWhen `track_total_hits` is not provided to
`fetchSearchResults`, the\nvalue is set to `false`. As a result, the
`search` api does not include\ntotal hit count in its response. Thus,
the total count of hit is 0 and\nonPaginate results in error. This PR
sets `track_total_hits` as an\noptional argument in
`fetchSearchResults`\n\n**Note**\nOne other option would be to set
`track_total_hits` to true but, based\non
this\n[documentation](https://www.elastic.co/docs/solutions/search/the-search-api#track-total-hits)\nsetting
`track_total_hits` to true would affect query
performance.\n\n```\nSetting 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.\n\n````\n\n\n\nhttps://github.com/user-attachments/assets/4284e88f-2614-4fbe-a0eb-1980355f5bff\n\n\n\n\n###
Checklist\n\n- [x] [Unit or
functional\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\nwere
updated or added to match the most common
scenarios","sha":"69d71244d67c7659590aa04f04cea5dd06e2d290"}},{"branch":"8.19","label":"v8.19.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->

Co-authored-by: Saarika Bhasi <55930906+saarikabhasi@users.noreply.github.com>
kibanamachine added a commit that referenced this pull request Apr 29, 2025
) (#219577)

# Backport

This will backport the following commits from `main` to `8.18`:
- [[Search] Fix content Indices documents error on paginate
(#219471)](#219471)

<!--- Backport version: 9.6.6 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sorenlouv/backport)

<!--BACKPORT [{"author":{"name":"Saarika
Bhasi","email":"55930906+saarikabhasi@users.noreply.github.com"},"sourceCommit":{"committedDate":"2025-04-29T15:24:07Z","message":"[Search]
Fix content Indices documents error on paginate (#219471)\n\nInitially
added fix in `8.17` branch
in\n[PR](#219411), but need
this\nchange in `main`, `8.18`, `8.19` & `9.0.0` and the file's paths
are\ndifferent in all versions(main, 8.18/8.19, 8.17, 9.0.0).\n\nCreated
this new PR, adding fix in `main` & will try to backport to\nother
versions.\n\n## Summary\nWhen `track_total_hits` is not provided to
`fetchSearchResults`, the\nvalue is set to `false`. As a result, the
`search` api does not include\ntotal hit count in its response. Thus,
the total count of hit is 0 and\nonPaginate results in error. This PR
sets `track_total_hits` as an\noptional argument in
`fetchSearchResults`\n\n**Note**\nOne other option would be to set
`track_total_hits` to true but, based\non
this\n[documentation](https://www.elastic.co/docs/solutions/search/the-search-api#track-total-hits)\nsetting
`track_total_hits` to true would affect query
performance.\n\n```\nSetting 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.\n\n````\n\n\n\nhttps://github.com/user-attachments/assets/4284e88f-2614-4fbe-a0eb-1980355f5bff\n\n\n\n\n###
Checklist\n\n- [x] [Unit or
functional\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\nwere
updated or added to match the most common
scenarios","sha":"69d71244d67c7659590aa04f04cea5dd06e2d290","branchLabelMapping":{"^v9.1.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","v9.0.0","Team:Search","backport:version","v8.17.0","v8.18.0","v9.1.0","v8.19.0"],"title":"[Search]
Fix content Indices documents error on
paginate","number":219471,"url":"https://github.com/elastic/kibana/pull/219471","mergeCommit":{"message":"[Search]
Fix content Indices documents error on paginate (#219471)\n\nInitially
added fix in `8.17` branch
in\n[PR](#219411), but need
this\nchange in `main`, `8.18`, `8.19` & `9.0.0` and the file's paths
are\ndifferent in all versions(main, 8.18/8.19, 8.17, 9.0.0).\n\nCreated
this new PR, adding fix in `main` & will try to backport to\nother
versions.\n\n## Summary\nWhen `track_total_hits` is not provided to
`fetchSearchResults`, the\nvalue is set to `false`. As a result, the
`search` api does not include\ntotal hit count in its response. Thus,
the total count of hit is 0 and\nonPaginate results in error. This PR
sets `track_total_hits` as an\noptional argument in
`fetchSearchResults`\n\n**Note**\nOne other option would be to set
`track_total_hits` to true but, based\non
this\n[documentation](https://www.elastic.co/docs/solutions/search/the-search-api#track-total-hits)\nsetting
`track_total_hits` to true would affect query
performance.\n\n```\nSetting 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.\n\n````\n\n\n\nhttps://github.com/user-attachments/assets/4284e88f-2614-4fbe-a0eb-1980355f5bff\n\n\n\n\n###
Checklist\n\n- [x] [Unit or
functional\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\nwere
updated or added to match the most common
scenarios","sha":"69d71244d67c7659590aa04f04cea5dd06e2d290"}},"sourceBranch":"main","suggestedTargetBranches":["9.0","8.17","8.18","8.19"],"targetPullRequestStates":[{"branch":"9.0","label":"v9.0.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"8.17","label":"v8.17.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"8.18","label":"v8.18.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v9.1.0","branchLabelMappingKey":"^v9.1.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/219471","number":219471,"mergeCommit":{"message":"[Search]
Fix content Indices documents error on paginate (#219471)\n\nInitially
added fix in `8.17` branch
in\n[PR](#219411), but need
this\nchange in `main`, `8.18`, `8.19` & `9.0.0` and the file's paths
are\ndifferent in all versions(main, 8.18/8.19, 8.17, 9.0.0).\n\nCreated
this new PR, adding fix in `main` & will try to backport to\nother
versions.\n\n## Summary\nWhen `track_total_hits` is not provided to
`fetchSearchResults`, the\nvalue is set to `false`. As a result, the
`search` api does not include\ntotal hit count in its response. Thus,
the total count of hit is 0 and\nonPaginate results in error. This PR
sets `track_total_hits` as an\noptional argument in
`fetchSearchResults`\n\n**Note**\nOne other option would be to set
`track_total_hits` to true but, based\non
this\n[documentation](https://www.elastic.co/docs/solutions/search/the-search-api#track-total-hits)\nsetting
`track_total_hits` to true would affect query
performance.\n\n```\nSetting 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.\n\n````\n\n\n\nhttps://github.com/user-attachments/assets/4284e88f-2614-4fbe-a0eb-1980355f5bff\n\n\n\n\n###
Checklist\n\n- [x] [Unit or
functional\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\nwere
updated or added to match the most common
scenarios","sha":"69d71244d67c7659590aa04f04cea5dd06e2d290"}},{"branch":"8.19","label":"v8.19.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->

Co-authored-by: Saarika Bhasi <55930906+saarikabhasi@users.noreply.github.com>
saarikabhasi added a commit that referenced this pull request Apr 29, 2025
#21… (#219603)

This reverts commit 0e9c857.

## Summary

Reverting changes from
[PR](#219471) that adds changes to
`8.17 ` branch directly. reverting to have clean history. Will try
manual backport from [PR](#219471)
that went into main, other 8.x branches.


### Checklist

- [ ] [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
saarikabhasi added a commit to saarikabhasi/kibana that referenced this pull request Apr 29, 2025
)

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
Copy link
Copy Markdown
Member Author

💚 All backports created successfully

Status Branch Result
8.17

Note: Successful backport PRs will be merged automatically after passing CI.

Questions ?

Please refer to the Backport tool documentation

akowalska622 pushed a commit to akowalska622/kibana that referenced this pull request Apr 30, 2025
)

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
saarikabhasi added a commit that referenced this pull request Apr 30, 2025
) (#219626)

# Backport

This will backport the following commits from `main` to `8.17`:
- [[Search] Fix content Indices documents error on paginate
(#219471)](#219471)

<!--- Backport version: 9.6.6 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sorenlouv/backport)

<!--BACKPORT [{"author":{"name":"Saarika
Bhasi","email":"55930906+saarikabhasi@users.noreply.github.com"},"sourceCommit":{"committedDate":"2025-04-29T15:24:07Z","message":"[Search]
Fix content Indices documents error on paginate (#219471)\n\nInitially
added fix in `8.17` branch
in\n[PR](#219411), but need
this\nchange in `main`, `8.18`, `8.19` & `9.0.0` and the file's paths
are\ndifferent in all versions(main, 8.18/8.19, 8.17, 9.0.0).\n\nCreated
this new PR, adding fix in `main` & will try to backport to\nother
versions.\n\n## Summary\nWhen `track_total_hits` is not provided to
`fetchSearchResults`, the\nvalue is set to `false`. As a result, the
`search` api does not include\ntotal hit count in its response. Thus,
the total count of hit is 0 and\nonPaginate results in error. This PR
sets `track_total_hits` as an\noptional argument in
`fetchSearchResults`\n\n**Note**\nOne other option would be to set
`track_total_hits` to true but, based\non
this\n[documentation](https://www.elastic.co/docs/solutions/search/the-search-api#track-total-hits)\nsetting
`track_total_hits` to true would affect query
performance.\n\n```\nSetting 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.\n\n````\n\n\n\nhttps://github.com/user-attachments/assets/4284e88f-2614-4fbe-a0eb-1980355f5bff\n\n\n\n\n###
Checklist\n\n- [x] [Unit or
functional\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\nwere
updated or added to match the most common
scenarios","sha":"69d71244d67c7659590aa04f04cea5dd06e2d290","branchLabelMapping":{"^v9.1.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","v9.0.0","Team:Search","backport:version","v8.17.0","v8.18.0","v9.1.0","v8.19.0","v8.18.1","v9.0.1"],"title":"[Search]
Fix content Indices documents error on
paginate","number":219471,"url":"https://github.com/elastic/kibana/pull/219471","mergeCommit":{"message":"[Search]
Fix content Indices documents error on paginate (#219471)\n\nInitially
added fix in `8.17` branch
in\n[PR](#219411), but need
this\nchange in `main`, `8.18`, `8.19` & `9.0.0` and the file's paths
are\ndifferent in all versions(main, 8.18/8.19, 8.17, 9.0.0).\n\nCreated
this new PR, adding fix in `main` & will try to backport to\nother
versions.\n\n## Summary\nWhen `track_total_hits` is not provided to
`fetchSearchResults`, the\nvalue is set to `false`. As a result, the
`search` api does not include\ntotal hit count in its response. Thus,
the total count of hit is 0 and\nonPaginate results in error. This PR
sets `track_total_hits` as an\noptional argument in
`fetchSearchResults`\n\n**Note**\nOne other option would be to set
`track_total_hits` to true but, based\non
this\n[documentation](https://www.elastic.co/docs/solutions/search/the-search-api#track-total-hits)\nsetting
`track_total_hits` to true would affect query
performance.\n\n```\nSetting 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.\n\n````\n\n\n\nhttps://github.com/user-attachments/assets/4284e88f-2614-4fbe-a0eb-1980355f5bff\n\n\n\n\n###
Checklist\n\n- [x] [Unit or
functional\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\nwere
updated or added to match the most common
scenarios","sha":"69d71244d67c7659590aa04f04cea5dd06e2d290"}},"sourceBranch":"main","suggestedTargetBranches":["8.17"],"targetPullRequestStates":[{"branch":"9.0","label":"v9.0.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"url":"https://github.com/elastic/kibana/pull/219579","number":219579,"state":"MERGED","mergeCommit":{"sha":"6bca376012094c252dae8e582893b46f1eda8fda","message":"[9.0]
[Search] Fix content Indices documents error on paginate (#219471)
(#219579)\n\n# Backport\n\nThis will backport the following commits from
`main` to `9.0`:\n- [[Search] Fix content Indices documents error on
paginate\n(#219471)](https://github.com/elastic/kibana/pull/219471)\n\n\n\n###
Questions ?\nPlease refer to the [Backport
tool\ndocumentation](https://github.com/sorenlouv/backport)\n\n\n\nCo-authored-by:
Saarika Bhasi
<55930906+saarikabhasi@users.noreply.github.com>"}},{"branch":"8.17","label":"v8.17.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"8.18","label":"v8.18.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"url":"https://github.com/elastic/kibana/pull/219577","number":219577,"state":"MERGED","mergeCommit":{"sha":"296b3c22d31c66dc46aec93051e371b30c286d8c","message":"[8.18]
[Search] Fix content Indices documents error on paginate (#219471)
(#219577)\n\n# Backport\n\nThis will backport the following commits from
`main` to `8.18`:\n- [[Search] Fix content Indices documents error on
paginate\n(#219471)](https://github.com/elastic/kibana/pull/219471)\n\n\n\n###
Questions ?\nPlease refer to the [Backport
tool\ndocumentation](https://github.com/sorenlouv/backport)\n\n\n\nCo-authored-by:
Saarika Bhasi
<55930906+saarikabhasi@users.noreply.github.com>"}},{"branch":"main","label":"v9.1.0","branchLabelMappingKey":"^v9.1.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/219471","number":219471,"mergeCommit":{"message":"[Search]
Fix content Indices documents error on paginate (#219471)\n\nInitially
added fix in `8.17` branch
in\n[PR](#219411), but need
this\nchange in `main`, `8.18`, `8.19` & `9.0.0` and the file's paths
are\ndifferent in all versions(main, 8.18/8.19, 8.17, 9.0.0).\n\nCreated
this new PR, adding fix in `main` & will try to backport to\nother
versions.\n\n## Summary\nWhen `track_total_hits` is not provided to
`fetchSearchResults`, the\nvalue is set to `false`. As a result, the
`search` api does not include\ntotal hit count in its response. Thus,
the total count of hit is 0 and\nonPaginate results in error. This PR
sets `track_total_hits` as an\noptional argument in
`fetchSearchResults`\n\n**Note**\nOne other option would be to set
`track_total_hits` to true but, based\non
this\n[documentation](https://www.elastic.co/docs/solutions/search/the-search-api#track-total-hits)\nsetting
`track_total_hits` to true would affect query
performance.\n\n```\nSetting 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.\n\n````\n\n\n\nhttps://github.com/user-attachments/assets/4284e88f-2614-4fbe-a0eb-1980355f5bff\n\n\n\n\n###
Checklist\n\n- [x] [Unit or
functional\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\nwere
updated or added to match the most common
scenarios","sha":"69d71244d67c7659590aa04f04cea5dd06e2d290"}},{"branch":"8.19","label":"v8.19.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"url":"https://github.com/elastic/kibana/pull/219578","number":219578,"state":"MERGED","mergeCommit":{"sha":"7790ebc7b5511c07aa057a085a349647381f5c31","message":"[8.19]
[Search] Fix content Indices documents error on paginate (#219471)
(#219578)\n\n# Backport\n\nThis will backport the following commits from
`main` to `8.19`:\n- [[Search] Fix content Indices documents error on
paginate\n(#219471)](https://github.com/elastic/kibana/pull/219471)\n\n\n\n###
Questions ?\nPlease refer to the [Backport
tool\ndocumentation](https://github.com/sorenlouv/backport)\n\n\n\nCo-authored-by:
Saarika Bhasi <55930906+saarikabhasi@users.noreply.github.com>"}}]}]
BACKPORT-->
@mistic
Copy link
Copy Markdown
Contributor

mistic commented May 6, 2025

This PR didn't make it into the latest 8.17.6 BC. Updating the labels.

akowalska622 pushed a commit to akowalska622/kibana that referenced this pull request May 29, 2025
)

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants