mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 01:38:56 -04:00
[ES body
removal] @elastic/observability-ui
(#204873)
This commit is contained in:
parent
777897cfa7
commit
e01208030b
4 changed files with 39 additions and 40 deletions
|
@ -66,7 +66,7 @@ export async function analyzeDocuments({
|
|||
})
|
||||
.then((response) => ({
|
||||
hits: response.hits.hits.map((hit) =>
|
||||
mapValues(hit.fields!, (value) => (value.length === 1 ? value[0] : value))
|
||||
mapValues(hit.fields!, (value) => (value?.length === 1 ? value[0] : value))
|
||||
),
|
||||
total: response.hits.total,
|
||||
})),
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* 2.0.
|
||||
*/
|
||||
|
||||
import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
|
||||
import type * as estypes from '@elastic/elasticsearch/lib/api/types';
|
||||
import { DataPublicPluginStart } from '@kbn/data-plugin/public';
|
||||
import type { ESSearchResponse } from '@kbn/es-types';
|
||||
import { useKibana } from '@kbn/kibana-react-plugin/public';
|
||||
|
|
|
@ -92,46 +92,44 @@ export const useValuesList = ({
|
|||
const { data, loading } = useEsSearch(
|
||||
createEsParams({
|
||||
index: dataViewTitle!,
|
||||
body: {
|
||||
query: {
|
||||
bool: {
|
||||
filter: [
|
||||
...(filters ?? []),
|
||||
...(from && to
|
||||
? [
|
||||
{
|
||||
range: {
|
||||
'@timestamp': {
|
||||
gte: from,
|
||||
lte: to,
|
||||
},
|
||||
},
|
||||
},
|
||||
]
|
||||
: []),
|
||||
],
|
||||
},
|
||||
},
|
||||
size: 0,
|
||||
aggs: {
|
||||
values: {
|
||||
terms: {
|
||||
field: sourceField,
|
||||
size: 50,
|
||||
...(query ? { include: includeClause } : {}),
|
||||
},
|
||||
...(cardinalityField
|
||||
? {
|
||||
aggs: {
|
||||
count: {
|
||||
cardinality: {
|
||||
field: cardinalityField,
|
||||
query: {
|
||||
bool: {
|
||||
filter: [
|
||||
...(filters ?? []),
|
||||
...(from && to
|
||||
? [
|
||||
{
|
||||
range: {
|
||||
'@timestamp': {
|
||||
gte: from,
|
||||
lte: to,
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
: {}),
|
||||
]
|
||||
: []),
|
||||
],
|
||||
},
|
||||
},
|
||||
size: 0,
|
||||
aggs: {
|
||||
values: {
|
||||
terms: {
|
||||
field: sourceField,
|
||||
size: 50,
|
||||
...(query ? { include: includeClause } : {}),
|
||||
},
|
||||
...(cardinalityField
|
||||
? {
|
||||
aggs: {
|
||||
count: {
|
||||
cardinality: {
|
||||
field: cardinalityField,
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
: {}),
|
||||
},
|
||||
},
|
||||
}),
|
||||
|
|
|
@ -5,10 +5,11 @@
|
|||
* 2.0.
|
||||
*/
|
||||
|
||||
import type { QueryDslQueryContainer } from '@elastic/elasticsearch/lib/api/types';
|
||||
import { kqlQuerySchema, QuerySchema } from '@kbn/slo-schema';
|
||||
import { buildEsQuery, fromKueryExpression, toElasticsearchQuery } from '@kbn/es-query';
|
||||
|
||||
export function getElasticsearchQueryOrThrow(kuery: QuerySchema = '') {
|
||||
export function getElasticsearchQueryOrThrow(kuery: QuerySchema = ''): QueryDslQueryContainer {
|
||||
try {
|
||||
if (kqlQuerySchema.is(kuery)) {
|
||||
return toElasticsearchQuery(fromKueryExpression(kuery));
|
||||
|
@ -23,6 +24,6 @@ export function getElasticsearchQueryOrThrow(kuery: QuerySchema = '') {
|
|||
);
|
||||
}
|
||||
} catch (err) {
|
||||
return [];
|
||||
return [] as QueryDslQueryContainer;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue