mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 01:38:56 -04:00
# Backport This will backport the following commits from `main` to `8.6`: - [[Uptime] Monitor list fix default search behaviour (#147336)](https://github.com/elastic/kibana/pull/147336) <!--- Backport version: 8.9.7 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) <!--BACKPORT [{"author":{"name":"Shahzad","email":"shahzad31comp@gmail.com"},"sourceCommit":{"committedDate":"2022-12-12T14:26:07Z","message":"[Uptime] Monitor list fix default search behaviour (#147336)\n\nCo-authored-by: Abdul Wahab Zahid <awahab07@yahoo.com>\r\nFixes https://github.com/elastic/kibana/issues/147245","sha":"80a6e6c6d7fedcf690afeabeb75e6683e274f2ea","branchLabelMapping":{"^v8.7.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["Team:uptime","release_note:skip","v8.6.0","v8.7.0"],"number":147336,"url":"https://github.com/elastic/kibana/pull/147336","mergeCommit":{"message":"[Uptime] Monitor list fix default search behaviour (#147336)\n\nCo-authored-by: Abdul Wahab Zahid <awahab07@yahoo.com>\r\nFixes https://github.com/elastic/kibana/issues/147245","sha":"80a6e6c6d7fedcf690afeabeb75e6683e274f2ea"}},"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/147336","number":147336,"mergeCommit":{"message":"[Uptime] Monitor list fix default search behaviour (#147336)\n\nCo-authored-by: Abdul Wahab Zahid <awahab07@yahoo.com>\r\nFixes https://github.com/elastic/kibana/issues/147245","sha":"80a6e6c6d7fedcf690afeabeb75e6683e274f2ea"}}]}] BACKPORT--> Co-authored-by: Shahzad <shahzad31comp@gmail.com>
This commit is contained in:
parent
cde67e90d2
commit
7d81c5133e
2 changed files with 57 additions and 2 deletions
|
@ -0,0 +1,55 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
import { getQueryStringFilter } from './get_query_string_filter';
|
||||
|
||||
describe('get_query_string_filter', () => {
|
||||
it('should return query string filter', () => {
|
||||
expect(getQueryStringFilter('test')).toEqual({
|
||||
query_string: {
|
||||
query: '*test* or tags:test*',
|
||||
fields: [
|
||||
'monitor.id.text',
|
||||
'monitor.name.text',
|
||||
'url.full.text',
|
||||
'synthetics.step.name',
|
||||
'synthetics.journey.name',
|
||||
],
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
it('port filter in case query is number', () => {
|
||||
expect(getQueryStringFilter('443')).toEqual({
|
||||
query_string: {
|
||||
query: 'url.port:443 or 443',
|
||||
fields: [
|
||||
'monitor.id.text',
|
||||
'monitor.name.text',
|
||||
'url.full.text',
|
||||
'synthetics.step.name',
|
||||
'synthetics.journey.name',
|
||||
],
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
it('do not wrap if it already has reserved char', () => {
|
||||
expect(getQueryStringFilter('test*')).toEqual({
|
||||
query_string: {
|
||||
query: 'test*',
|
||||
fields: [
|
||||
'monitor.id.text',
|
||||
'monitor.name.text',
|
||||
'url.full.text',
|
||||
'synthetics.step.name',
|
||||
'synthetics.journey.name',
|
||||
],
|
||||
},
|
||||
});
|
||||
});
|
||||
});
|
|
@ -8,8 +8,8 @@
|
|||
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 user doesn't specify any query string syntax we use wildcard by default
|
||||
queryString = `*${query}* or tags:${query}*`;
|
||||
}
|
||||
|
||||
if (Number(query)) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue