mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 17:28:26 -04:00
# Backport This will backport the following commits from `main` to `8.17`: - [[ES `body` removal] `@elastic/observability-ui` (#204873)](https://github.com/elastic/kibana/pull/204873) <!--- Backport version: 9.4.3 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) <!--BACKPORT [{"author":{"name":"Alejandro Fernández Haro","email":"alejandro.haro@elastic.co"},"sourceCommit":{"committedDate":"2025-02-02T17:10:02Z","message":"[ES `body` removal] `@elastic/observability-ui` (#204873)","sha":"e01208030bf1faed9990edf4e965265fca9d2502","branchLabelMapping":{"^v9.1.0$":"main","^v8.19.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","Team:Observability","backport:prev-major","ci:build-serverless-image","Team:obs-ux-management","elasticsearch-js-9","v9.1.0"],"title":"[ES `body` removal] `@elastic/observability-ui`","number":204873,"url":"https://github.com/elastic/kibana/pull/204873","mergeCommit":{"message":"[ES `body` removal] `@elastic/observability-ui` (#204873)","sha":"e01208030bf1faed9990edf4e965265fca9d2502"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v9.1.0","branchLabelMappingKey":"^v9.1.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/204873","number":204873,"mergeCommit":{"message":"[ES `body` removal] `@elastic/observability-ui` (#204873)","sha":"e01208030bf1faed9990edf4e965265fca9d2502"}},{"url":"https://github.com/elastic/kibana/pull/209222","number":209222,"branch":"9.0","state":"OPEN"}]}] BACKPORT--> Co-authored-by: Alejandro Fernández Haro <alejandro.haro@elastic.co>
This commit is contained in:
parent
935df3c92c
commit
9a0bab97d8
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