-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Metrics UI] Fix hasData call to ensure it has data not just indices (#…
…72969) (#73668) * [Metrics UI] Fix hasData call to ensure it has data not just indices * Fixing formatting Co-authored-by: Elastic Machine <[email protected]> Co-authored-by: Elastic Machine <[email protected]>
- Loading branch information
1 parent
fcf0b63
commit 1eddefa
Showing
4 changed files
with
51 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
import { RequestHandlerContext } from 'src/core/server'; | ||
import { CallWithRequestParams, InfraDatabaseSearchResponse } from './adapters/framework'; | ||
import { KibanaFramework } from './adapters/framework/kibana_framework_adapter'; | ||
|
||
export const createSearchClient = ( | ||
requestContext: RequestHandlerContext, | ||
framework: KibanaFramework | ||
) => <Hit = {}, Aggregation = undefined>( | ||
opts: CallWithRequestParams | ||
): Promise<InfraDatabaseSearchResponse<Hit, Aggregation>> => | ||
framework.callWithRequest(requestContext, 'search', opts); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import { ESSearchClient } from '../snapshot'; | ||
|
||
export const hasData = async (index: string, client: ESSearchClient) => { | ||
const params = { | ||
index, | ||
allowNoIndices: true, | ||
terminate_after: 1, | ||
ignoreUnavailable: true, | ||
body: { | ||
size: 0, | ||
}, | ||
}; | ||
const results = await client(params); | ||
return results.hits.total.value !== 0; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters