import { AutoCompleteItem } from '../../../common/entities/AutoCompleteItem'; import { SearchResultDTO } from '../../../common/entities/SearchResultDTO'; import { PhotoEntity } from './enitites/PhotoEntity'; import { Brackets, ObjectLiteral, SelectQueryBuilder } from 'typeorm'; import { SearchQueryDTO, SearchQueryTypes } from '../../../common/entities/SearchQueryDTO'; import { SortingMethod } from '../../../common/entities/SortingMethods'; import { SessionContext } from '../SessionContext'; export declare class SearchManager { private DIRECTORY_SELECT; private queryIdBase; private static likeValue; /** * A text condition that ignores the accents and the case as far as the DB can, see sqlFoldsText(). * @param escape '\' escapes the wildcards of the value (MySQL does it by default, SQLite only with ESCAPE) * @param wrap an SQL expression around the compared text (not around the IS NOT NULL check) */ private static like; private static containsText; static setSorting(query: SelectQueryBuilder, sortings: SortingMethod[]): SelectQueryBuilder; private static autoCompleteItemsUnique; autocomplete(session: SessionContext, value: string, type: SearchQueryTypes): Promise; search(session: SessionContext, queryIN: SearchQueryDTO): Promise; getNMedia(session: SessionContext, query: SearchQueryDTO, sortings: SortingMethod[], take: number, photoOnly?: boolean): Promise; getCount(session: SessionContext, query: SearchQueryDTO): Promise; prepareAndBuildWhereQuery(queryIN: SearchQueryDTO, directoryOnly?: false, aliases?: Record): Promise; /** * directoryOnly: null if the query has no directory related part */ prepareAndBuildWhereQuery(queryIN: SearchQueryDTO, directoryOnly: boolean, aliases?: Record): Promise; prepareQuery(queryIN: SearchQueryDTO): Promise; /** * Builds the SQL Where query from search query * @param query input search query * @param directoryOnly Only builds directory related queries * @param aliases for SQL alias mapping * @private */ buildWhereQuery(query: SearchQueryDTO, directoryOnly?: boolean, aliases?: Record): Brackets; hasDirectoryQuery(query: SearchQueryDTO): boolean; protected flattenSameOfQueries(query: SearchQueryDTO): SearchQueryDTO; /** * A directory glob with a trailing '/*' means the directory itself and everything below it. * The SQL glob only matches below the directory, so the directory itself is added as an exact match. * See SearchQueryUtils.matchDirectorySearch for the same logic without DB. */ protected expandDirectoryGlobs(query: SearchQueryDTO): SearchQueryDTO; protected convertMatchTypeToGlob(query: SearchQueryDTO): SearchQueryDTO; /** * Assigning IDs to search queries. It is a help / simplification to typeorm, * so less parameters are needed to pass down to SQL. * Witch SOME_OF query the number of WHERE constrains have O(N!) complexity */ private assignQueryIDs; /** * Returns only those parts of a query tree that only contains directory-related search queries */ private filterDirectoryQuery; private getGPSData; private encapsulateAutoComplete; } export interface SearchQueryDTOWithID extends SearchQueryDTO { queryId: string; }