Repository navigation
Conversation
…ments
Replace the internal index_doc_count and indices/{indexName}/sample routes with
browser-side data plugin searches: the ES|QL search strategy for document counts
and the es search strategy for the sample documents on the index details page.
Co-authored-by: Cursor <cursoragent@cursor.com>
|
🤖 Jobs for this PR can be triggered through checkboxes. 🚧
ℹ️ To trigger the CI, please tick the checkbox below 👇
|
|
Pinging @elastic/kibana-management (Team:Kibana Management) |
| @@ -92,7 +92,7 @@ describe('<IndexDetailsPage />', () => { | |||
| testUserStartPrivilegesResponse | |||
| ); | |||
| httpRequestsMockHelpers.setLoadIndexDocCountResponse({ | |||
There was a problem hiding this comment.
Severity: P3 (Low)
Register a sample search response in this suite and assert that the Overview renders it. Nothing sets up /internal/search/es, so the HTTP mock returns {} and the sample hook hits a rawResponse.hits error. The page tests can pass without ever exercising a successful preview through the new search wiring.
Generated by Libra. React with 👍 or 👎 to give feedback on this comment.
| @@ -96,8 +102,8 @@ export const DetailsPageContent: FunctionComponent<Props> = ({ | |||
| data: documentsSampleData, | |||
| isLoading: isDocumentsSampleLoading, | |||
There was a problem hiding this comment.
Severity: P3 (Low)
isLoading from useQuery is only true when there's no cached data yet, so it stays false during refetch(). useRequest used to set isLoading to true on every resend. As a result, clicking Refresh in the Data preview (or the onIndexRefresh refetch after an index action) no longer shows the button spinner or the EuiProgress bar. After a failed load, the error banner also stays up while the retry runs, because showErrorBanner is error && !isLoading. Use isFetching, or isLoading || isRefetching, to keep the old loading feedback. The shared module-level QueryClient also serves cached samples when you reopen an index, and with this change nothing shows that they are being refreshed.
Generated by Libra. Specialist: libra-complexity. React with 👍 or 👎 to give feedback on this comment.
| search<IEsSearchRequest, IEsSearchResponse>( | ||
| { | ||
| params: { | ||
| index: indexName, |
There was a problem hiding this comment.
Severity: P3 (Low)
Set ignore_unavailable: false for this single-index preview. The es strategy defaults it to true, so a closed or recently deleted index can look like an empty one: the preview disappears instead of telling the user why the documents could not be loaded.
Generated by Libra. React with 👍 or 👎 to give feedback on this comment.
| responseType: 'json', | ||
| body: JSON.stringify({ indexNames }), | ||
| apiTest.beforeAll(async ({ requestAuth }) => { | ||
| credentials = await requestAuth.getApiKey('admin'); |
There was a problem hiding this comment.
Severity: P3 (Low)
Use a scoped interactive session for the replacement search endpoint. The admin API key can return the expected counts even if the new route rejects browser sessions or requires privileges beyond read access to the test indices. Keep setup on esClient, but make the assertions with a samlAuth cookie for a role scoped to the test indices.
Generated by Libra. Specialist: scout. React with 👍 or 👎 to give feedback on this comment.
💚 Build Succeeded
Metrics [docs]Page load bundle
Unknown metric groupsshared async chunks total size
total optimizer output size
warm start memory
cc @mattkime |
…306623 Restore the index_doc_count and documents sample routes and their callers so this PR only contains the es_client changes, and commit the user status route files restored when reverting the security API usage. Co-authored-by: Cursor <cursoragent@cursor.com>
Summary
Index Management ran two queries through its own server routes. The browser already has a way to run them: the data plugin's search service. This PR removes both routes and runs the queries from the browser with
data.search.POST /internal/index_management/index_doc_countdata.searchwith the ES|QL search strategy (esql)GET /internal/index_management/indices/{indexName}/sampledata.searchwith the Elasticsearch search strategy (es)The queries themselves are unchanged:
FROM ... METADATA _index | STATS count() BY _indexquery withallow_partial_results: true. The query builder and response mapping now live incommon/lib/index_doc_count_query.ts.quoteEsqlIndexNamemoved fromserver/libtocommon/libso the browser can use it._sourceincluding_inference_fields, all fields, sorted by_docdescending. The hook now usesuseQuery, with retries and refetch on window focus turned off to match the previoususeRequestbehavior.datais now a required plugin of Index Management, and the data plugin's start contract is passed to components through the app context (plugins.data).This PR is split out of #246293 and has no dependency on the es_client plugin.
Behavior notes
essearch strategy addsignore_unavailable: trueto every request. If the index is unavailable, the sample now comes back empty instead of returning an error like the old route did.handleEsError. The overview and quick stats only read the error message, or fall back to the metadata doc count.Testing
fetchIndexDocCountsanduseLoadIndexDocumentsSample(request shape, count mapping, errors).docCountApi,QuickStatsand client integration tests to mock/internal/search/{strategy}.index_doc_count.spec.tsnow sends the browser's query throughinternal/search/esql.