Commit 69d7124
authored
[Search] Fix content Indices documents error on paginate (#219471)
Initially added fix in `8.17` branch in
[PR](#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 scenarios1 parent 125fc2a commit 69d7124
2 files changed
Lines changed: 5 additions & 5 deletions
File tree
Lines changed: 4 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
86 | 86 | | |
87 | 87 | | |
88 | 88 | | |
89 | | - | |
| 89 | + | |
90 | 90 | | |
91 | 91 | | |
92 | 92 | | |
| |||
108 | 108 | | |
109 | 109 | | |
110 | 110 | | |
111 | | - | |
| 111 | + | |
112 | 112 | | |
113 | 113 | | |
114 | 114 | | |
| |||
123 | 123 | | |
124 | 124 | | |
125 | 125 | | |
126 | | - | |
| 126 | + | |
127 | 127 | | |
128 | 128 | | |
129 | 129 | | |
| |||
151 | 151 | | |
152 | 152 | | |
153 | 153 | | |
154 | | - | |
| 154 | + | |
155 | 155 | | |
156 | 156 | | |
157 | 157 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
20 | | - | |
| 20 | + | |
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
| |||
0 commit comments