mirror of
https://github.com/open-metadata/OpenMetadata.git
synced 2025-08-24 17:08:28 +00:00
fix: GEN-1856 encode and escape search value for the tag search (#18285)
* fix: GEN-1856 encode and escape search value for the tag * fix test * add missing import (cherry picked from commit 3b182c91c8a53d11aa6fb5f880e917556cb087a7)
This commit is contained in:
parent
231cef6490
commit
2d4537c4d8
@ -16,6 +16,12 @@ import tagClassBase, { TagClassBase } from './TagClassBase';
|
|||||||
|
|
||||||
jest.mock('../rest/searchAPI');
|
jest.mock('../rest/searchAPI');
|
||||||
|
|
||||||
|
|
||||||
|
jest.mock('./StringsUtils', () => ({
|
||||||
|
getEncodedFqn: jest.fn().mockReturnValue('test'),
|
||||||
|
escapeESReservedCharacters: jest.fn().mockReturnValue('test'),
|
||||||
|
}));
|
||||||
|
|
||||||
describe('TagClassBase', () => {
|
describe('TagClassBase', () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
(searchQuery as jest.Mock).mockClear();
|
(searchQuery as jest.Mock).mockClear();
|
||||||
|
@ -13,11 +13,14 @@
|
|||||||
import { PAGE_SIZE } from '../constants/constants';
|
import { PAGE_SIZE } from '../constants/constants';
|
||||||
import { SearchIndex } from '../enums/search.enum';
|
import { SearchIndex } from '../enums/search.enum';
|
||||||
import { searchQuery } from '../rest/searchAPI';
|
import { searchQuery } from '../rest/searchAPI';
|
||||||
|
import { escapeESReservedCharacters, getEncodedFqn } from './StringsUtils';
|
||||||
|
|
||||||
class TagClassBase {
|
class TagClassBase {
|
||||||
public async getTags(searchText: string, page: number) {
|
public async getTags(searchText: string, page: number) {
|
||||||
|
// this is to esacpe and encode any chars which is known by ES search internally
|
||||||
|
const encodedValue = getEncodedFqn(escapeESReservedCharacters(searchText));
|
||||||
const res = await searchQuery({
|
const res = await searchQuery({
|
||||||
query: `*${searchText}*`,
|
query: `*${encodedValue}*`,
|
||||||
filters: 'disabled:false',
|
filters: 'disabled:false',
|
||||||
pageNumber: page,
|
pageNumber: page,
|
||||||
pageSize: PAGE_SIZE,
|
pageSize: PAGE_SIZE,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user