kibana/packages/kbn-discover-utils
Julia Rechkunova 110449df5c
[OnWeek][Discover] Allow to fetch more documents on Discover page (#163784)
> [!WARNING]
> Sorry, I had to recreate the PR
https://github.com/elastic/kibana/pull/157241
> Please submit your review again.

- Closes https://github.com/elastic/kibana/issues/155019

Per docs
https://www.elastic.co/guide/en/elasticsearch/reference/current/paginate-search-results.html
<img width="851" alt="Screenshot 2023-05-10 at 10 25 20"
src="b4b9fef4-7dd8-40ed-8244-343889fc4367">


## Summary

1. This PR improves `search_after` pagination for `date_nanos` time
fields. `sort` value will be returned from ES as a string instead of a
rounded and incorrect timestamp. This change allows to also simplify
logic on Surrounding document page.

Before:
<img width="400" alt="Screenshot 2023-05-08 at 17 36 19"
src="fd9f45c4-5dc2-4103-83b9-8810e3a6e0df">

After:
<img width="400" alt="Screenshot 2023-05-08 at 17 37 13"
src="fe9090c0-2116-4f77-9a57-a96ae6b00365">

2. Also in this PR we now allow users to load more documents within the
same time range. Once the button is pressed, it will load next portion
of documents (same "sampleSize" value will be used). Currently, we limit
max total loaded documents to 10000.

"Load more" demo:
![Aug-07-2023
16-23-28](53af9809-75cb-4b8a-8e99-d8f6d76b4981)

If refresh interval is on, the button becomes disabled:
![Aug-07-2023
16-24-58](85db6144-98eb-40b5-ac88-80ea728bcd6b)

Date nanos demo:
![Aug-07-2023
16-34-59](dc9fe0b1-e419-4c76-9fc6-79907b134e58)


100x Flaky test runner
https://buildkite.com/elastic/kibana-flaky-test-suite-runner/builds/2801

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
2023-08-17 20:31:21 +02:00
..
src [OnWeek][Discover] Allow to fetch more documents on Discover page (#163784) 2023-08-17 20:31:21 +02:00
index.ts Move constants into @kbn/discover-utils (#162360) 2023-07-26 14:11:30 -07:00
jest.config.js
kibana.jsonc
package.json Move constants into @kbn/discover-utils (#162360) 2023-07-26 14:11:30 -07:00
README.md
tsconfig.json Move more shared utils into @kbn/discover-utils (#162096) 2023-07-20 11:07:38 -07:00
types.ts Move more shared utils into @kbn/discover-utils (#162096) 2023-07-20 11:07:38 -07:00

@kbn/discover-utils

This is the package contains extracting parts of Discover for the usage in other unified components. This are mainly shared types, utils and mocks.