mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 09:48:58 -04:00
# Backport This will backport the following commits from `main` to `8.6`: - [[Uptime] Use query string for simple text search (#145533)](https://github.com/elastic/kibana/pull/145533) <!--- Backport version: 8.9.7 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) <!--BACKPORT [{"author":{"name":"Shahzad","email":"shahzad.muhammad@elastic.co"},"sourceCommit":{"committedDate":"2022-11-28T10:58:48Z","message":"[Uptime] Use query string for simple text search (#145533)\n\nCo-authored-by: Dominique Clarke <dominique.clarke@elastic.co>\r\nCo-authored-by: florent-leborgne <florent.leborgne@elastic.co>\r\nFixes https://github.com/elastic/kibana/issues/145530","sha":"35e581534c1cbdaaef911b3d4770216dacf8a34f","branchLabelMapping":{"^v8.7.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["bug","release_note:fix","Team:uptime","v8.6.0","v8.7.0"],"number":145533,"url":"https://github.com/elastic/kibana/pull/145533","mergeCommit":{"message":"[Uptime] Use query string for simple text search (#145533)\n\nCo-authored-by: Dominique Clarke <dominique.clarke@elastic.co>\r\nCo-authored-by: florent-leborgne <florent.leborgne@elastic.co>\r\nFixes https://github.com/elastic/kibana/issues/145530","sha":"35e581534c1cbdaaef911b3d4770216dacf8a34f"}},"sourceBranch":"main","suggestedTargetBranches":["8.6"],"targetPullRequestStates":[{"branch":"8.6","label":"v8.6.0","labelRegex":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v8.7.0","labelRegex":"^v8.7.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/145533","number":145533,"mergeCommit":{"message":"[Uptime] Use query string for simple text search (#145533)\n\nCo-authored-by: Dominique Clarke <dominique.clarke@elastic.co>\r\nCo-authored-by: florent-leborgne <florent.leborgne@elastic.co>\r\nFixes https://github.com/elastic/kibana/issues/145530","sha":"35e581534c1cbdaaef911b3d4770216dacf8a34f"}}]}] BACKPORT--> Co-authored-by: Shahzad <shahzad.muhammad@elastic.co>
This commit is contained in:
parent
461c04ec6c
commit
269987e42b
10 changed files with 70 additions and 64 deletions
|
@ -13,8 +13,8 @@ export const KQL_PLACE_HOLDER = i18n.translate('xpack.synthetics.kueryBar.search
|
|||
});
|
||||
|
||||
export const SIMPLE_SEARCH_PLACEHOLDER = i18n.translate(
|
||||
'xpack.synthetics.kueryBar.searchPlaceholder.simple',
|
||||
'xpack.synthetics.kueryBar.searchPlaceholder.simpleText',
|
||||
{
|
||||
defaultMessage: 'Search by monitor ID, name, or url (E.g. http:// )',
|
||||
defaultMessage: 'Search by monitor ID, name, URL, port or tags',
|
||||
}
|
||||
);
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
import React from 'react';
|
||||
import { OverviewPageComponent } from './overview';
|
||||
import { render } from '../lib/helper/rtl_helpers';
|
||||
import { SIMPLE_SEARCH_PLACEHOLDER } from '../components/overview/query_bar/translations';
|
||||
|
||||
describe('MonitorPage', () => {
|
||||
it('renders expected elements for valid props', async () => {
|
||||
|
@ -15,8 +16,6 @@ describe('MonitorPage', () => {
|
|||
|
||||
expect(await findByText('No uptime monitors found')).toBeInTheDocument();
|
||||
|
||||
expect(
|
||||
await findByPlaceholderText('Search by monitor ID, name, or url (E.g. http:// )')
|
||||
).toBeInTheDocument();
|
||||
expect(await findByPlaceholderText(SIMPLE_SEARCH_PLACEHOLDER)).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
|
|
|
@ -20,7 +20,7 @@ import { FilterGroup } from '../components/overview/filter_group/filter_group';
|
|||
|
||||
const EuiFlexItemStyled = styled(EuiFlexItem)`
|
||||
&& {
|
||||
min-width: 800px;
|
||||
min-width: 700px;
|
||||
@media only screen and (max-width: 1128px) {
|
||||
min-width: 500px;
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
* 2.0.
|
||||
*/
|
||||
|
||||
import { getQueryStringFilter } from './search/get_query_string_filter';
|
||||
import { getFilterClause } from '../helper';
|
||||
import { GetPingHistogramParams, HistogramResult } from '../../../../common/runtime_types';
|
||||
import { QUERY } from '../../../../common/constants';
|
||||
|
@ -38,6 +39,10 @@ export const getPingHistogram: UMElasticsearchQueryFn<
|
|||
|
||||
const minInterval = getHistogramInterval(from, to, QUERY.DEFAULT_BUCKET_COUNT);
|
||||
|
||||
if (query) {
|
||||
filter.push(getQueryStringFilter(query));
|
||||
}
|
||||
|
||||
const params = createEsQuery({
|
||||
body: {
|
||||
query: {
|
||||
|
@ -51,20 +56,6 @@ export const getPingHistogram: UMElasticsearchQueryFn<
|
|||
},
|
||||
EXCLUDE_RUN_ONCE_FILTER,
|
||||
],
|
||||
...(query
|
||||
? {
|
||||
minimum_should_match: 1,
|
||||
should: [
|
||||
{
|
||||
multi_match: {
|
||||
query: escape(query),
|
||||
type: 'phrase_prefix' as const,
|
||||
fields: ['monitor.id.text', 'monitor.name.text', 'url.full.text'],
|
||||
},
|
||||
},
|
||||
],
|
||||
}
|
||||
: {}),
|
||||
},
|
||||
},
|
||||
size: 0,
|
||||
|
|
|
@ -6,11 +6,15 @@
|
|||
*/
|
||||
|
||||
import type { ESFilter } from '@kbn/es-types';
|
||||
import { getQueryStringFilter } from './search/get_query_string_filter';
|
||||
import { UMElasticsearchQueryFn } from '../adapters';
|
||||
import { CONTEXT_DEFAULTS } from '../../../../common/constants';
|
||||
import { Snapshot } from '../../../../common/runtime_types';
|
||||
import { QueryContext } from './search';
|
||||
import { EXCLUDE_RUN_ONCE_FILTER } from '../../../../common/constants/client_defaults';
|
||||
import {
|
||||
EXCLUDE_RUN_ONCE_FILTER,
|
||||
SUMMARY_FILTER,
|
||||
} from '../../../../common/constants/client_defaults';
|
||||
|
||||
export interface GetSnapshotCountParams {
|
||||
dateRangeStart: string;
|
||||
|
@ -61,33 +65,15 @@ const statusCount = async (context: QueryContext): Promise<Snapshot> => {
|
|||
};
|
||||
|
||||
const statusCountBody = (filters: ESFilter[], context: QueryContext) => {
|
||||
if (context.query) {
|
||||
filters.push(getQueryStringFilter(context.query));
|
||||
}
|
||||
|
||||
return {
|
||||
size: 0,
|
||||
query: {
|
||||
bool: {
|
||||
...(context.query
|
||||
? {
|
||||
minimum_should_match: 1,
|
||||
should: [
|
||||
{
|
||||
multi_match: {
|
||||
query: escape(context.query),
|
||||
type: 'phrase_prefix',
|
||||
fields: ['monitor.id.text', 'monitor.name.text', 'url.full.text'],
|
||||
},
|
||||
},
|
||||
],
|
||||
}
|
||||
: {}),
|
||||
filter: [
|
||||
{
|
||||
exists: {
|
||||
field: 'summary',
|
||||
},
|
||||
},
|
||||
EXCLUDE_RUN_ONCE_FILTER,
|
||||
...filters,
|
||||
],
|
||||
filter: [SUMMARY_FILTER, EXCLUDE_RUN_ONCE_FILTER, ...filters],
|
||||
},
|
||||
},
|
||||
aggs: {
|
||||
|
|
|
@ -6,8 +6,12 @@
|
|||
*/
|
||||
|
||||
import { set } from 'lodash';
|
||||
import { getQueryStringFilter } from './get_query_string_filter';
|
||||
import { QueryContext } from './query_context';
|
||||
import { EXCLUDE_RUN_ONCE_FILTER } from '../../../../../common/constants/client_defaults';
|
||||
import {
|
||||
EXCLUDE_RUN_ONCE_FILTER,
|
||||
SUMMARY_FILTER,
|
||||
} from '../../../../../common/constants/client_defaults';
|
||||
|
||||
/**
|
||||
* This is the first phase of the query. In it, we find all monitor IDs that have ever matched the given filters.
|
||||
|
@ -52,29 +56,17 @@ const queryBody = async (queryContext: QueryContext, searchAfter: any, size: num
|
|||
filters.push({ match: { 'monitor.status': queryContext.statusFilter } });
|
||||
}
|
||||
|
||||
filters.push({ exists: { field: 'summary' } });
|
||||
filters.push(SUMMARY_FILTER, EXCLUDE_RUN_ONCE_FILTER);
|
||||
|
||||
filters.push(EXCLUDE_RUN_ONCE_FILTER);
|
||||
if (queryContext.query) {
|
||||
filters.push(getQueryStringFilter(queryContext.query));
|
||||
}
|
||||
|
||||
const body = {
|
||||
size: 0,
|
||||
query: {
|
||||
bool: {
|
||||
filter: filters,
|
||||
...(queryContext.query
|
||||
? {
|
||||
minimum_should_match: 1,
|
||||
should: [
|
||||
{
|
||||
multi_match: {
|
||||
query: escape(queryContext.query),
|
||||
type: 'phrase_prefix',
|
||||
fields: ['monitor.id.text', 'monitor.name.text', 'url.full.text'],
|
||||
},
|
||||
},
|
||||
],
|
||||
}
|
||||
: {}),
|
||||
},
|
||||
},
|
||||
aggs: {
|
||||
|
|
|
@ -0,0 +1,41 @@
|
|||
/*
|
||||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
||||
* or more contributor license agreements. Licensed under the Elastic License
|
||||
* 2.0; you may not use this file except in compliance with the Elastic License
|
||||
* 2.0.
|
||||
*/
|
||||
|
||||
export const getQueryStringFilter = (query: string) => {
|
||||
let queryString = query;
|
||||
if (hasReservedCharsF(query) && !includesOperator(query.toLowerCase())) {
|
||||
// if user doesn't specify any query string syntax we user wildcard buy default
|
||||
queryString = `${query}* or tags:${query}*`;
|
||||
}
|
||||
|
||||
if (Number(query)) {
|
||||
queryString = `url.port:${query} or ${query}`;
|
||||
}
|
||||
|
||||
return {
|
||||
query_string: {
|
||||
query: queryString,
|
||||
fields: [
|
||||
'monitor.id.text',
|
||||
'monitor.name.text',
|
||||
'url.full.text',
|
||||
'synthetics.step.name',
|
||||
'synthetics.journey.name',
|
||||
],
|
||||
},
|
||||
};
|
||||
};
|
||||
|
||||
const includesOperator = (query: string) => {
|
||||
return query.includes(' or ') || query.includes(' and ');
|
||||
};
|
||||
|
||||
// check if it has reserved characters for query string syntax
|
||||
const hasReservedCharsF = (str: string) => {
|
||||
const format = /^[a-zA-Z]+$/;
|
||||
return format.test(str);
|
||||
};
|
|
@ -30893,7 +30893,6 @@
|
|||
"xpack.synthetics.keyValuePairsField.value.ariaLabel": "Valeur",
|
||||
"xpack.synthetics.keyValuePairsField.value.label": "Valeur",
|
||||
"xpack.synthetics.kueryBar.searchPlaceholder.kql": "Rechercher à l'aide de la syntaxe KQL des ID, noms et types etc. de moniteurs (par ex. monitor.type: \"http\" AND tags: \"dev\")",
|
||||
"xpack.synthetics.kueryBar.searchPlaceholder.simple": "Rechercher par ID, nom ou URL de moniteur (par ex. http:// )",
|
||||
"xpack.synthetics.locationName.helpLinkAnnotation": "Ajouter un emplacement",
|
||||
"xpack.synthetics.management.confirmDescriptionLabel": "Cette action supprimera le moniteur mais conservera toute donnée collectée. Cette action ne peut pas être annulée.",
|
||||
"xpack.synthetics.management.deleteLabel": "Supprimer",
|
||||
|
|
|
@ -30869,7 +30869,6 @@
|
|||
"xpack.synthetics.keyValuePairsField.value.ariaLabel": "値",
|
||||
"xpack.synthetics.keyValuePairsField.value.label": "値",
|
||||
"xpack.synthetics.kueryBar.searchPlaceholder.kql": "KQL構文を使用して、モニターID、名前、タイプ(例:monitor.type: \"http\" AND tags: \"dev\")などを検索",
|
||||
"xpack.synthetics.kueryBar.searchPlaceholder.simple": "モニターID、名前、またはURL(例:http://)で検索",
|
||||
"xpack.synthetics.locationName.helpLinkAnnotation": "場所を追加",
|
||||
"xpack.synthetics.management.confirmDescriptionLabel": "このアクションにより、モニターが削除されますが、収集されたデータはすべて保持されます。この操作は元に戻すことができません。",
|
||||
"xpack.synthetics.management.deleteLabel": "削除",
|
||||
|
|
|
@ -30904,7 +30904,6 @@
|
|||
"xpack.synthetics.keyValuePairsField.value.ariaLabel": "值",
|
||||
"xpack.synthetics.keyValuePairsField.value.label": "值",
|
||||
"xpack.synthetics.kueryBar.searchPlaceholder.kql": "使用 kql 语法搜索监测 ID、名称和类型等(例如 monitor.type: \"http\" AND tags: \"dev\")",
|
||||
"xpack.synthetics.kueryBar.searchPlaceholder.simple": "按监测 ID、名称或 url(例如 http://)搜索",
|
||||
"xpack.synthetics.locationName.helpLinkAnnotation": "添加位置",
|
||||
"xpack.synthetics.management.confirmDescriptionLabel": "此操作将删除监测,但会保留收集的任何数据。此操作无法撤消。",
|
||||
"xpack.synthetics.management.deleteLabel": "删除",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue