Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ES body removal] @elastic/observability-ui #204873

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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,
})),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
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,
},
},
size: 0,
aggs: {
values: {
terms: {
field: sourceField,
size: 50,
...(query ? { include: includeClause } : {}),
},
...(cardinalityField
? {
aggs: {
count: {
cardinality: {
field: cardinalityField,
},
},
}
: {}),
},
},
}
: {}),
},
},
}),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand All @@ -23,6 +24,6 @@ export function getElasticsearchQueryOrThrow(kuery: QuerySchema = '') {
);
}
} catch (err) {
return [];
return [] as QueryDslQueryContainer;
}
}