mirror of
https://github.com/open-metadata/OpenMetadata.git
synced 2025-08-23 16:38:17 +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('./StringsUtils', () => ({
|
||||
getEncodedFqn: jest.fn().mockReturnValue('test'),
|
||||
escapeESReservedCharacters: jest.fn().mockReturnValue('test'),
|
||||
}));
|
||||
|
||||
describe('TagClassBase', () => {
|
||||
beforeEach(() => {
|
||||
(searchQuery as jest.Mock).mockClear();
|
||||
|
@ -13,11 +13,14 @@
|
||||
import { PAGE_SIZE } from '../constants/constants';
|
||||
import { SearchIndex } from '../enums/search.enum';
|
||||
import { searchQuery } from '../rest/searchAPI';
|
||||
import { escapeESReservedCharacters, getEncodedFqn } from './StringsUtils';
|
||||
|
||||
class TagClassBase {
|
||||
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({
|
||||
query: `*${searchText}*`,
|
||||
query: `*${encodedValue}*`,
|
||||
filters: 'disabled:false',
|
||||
pageNumber: page,
|
||||
pageSize: PAGE_SIZE,
|
||||
|
Loading…
x
Reference in New Issue
Block a user