mirror of
https://github.com/immich-app/immich.git
synced 2024-12-26 10:50:29 +02:00
chore(server): search filename using originalFileName (#7691)
This commit is contained in:
parent
4323d18387
commit
1eea547aa2
@ -35,7 +35,7 @@ export const ASSET_CHECKSUM_CONSTRAINT = 'UQ_assets_owner_library_checksum';
|
||||
@Index('IDX_day_of_month', { synchronize: false })
|
||||
@Index('IDX_month', { synchronize: false })
|
||||
@Index('IDX_originalPath_libraryId', ['originalPath', 'libraryId'])
|
||||
@Index('idx_originalpath_trigram', { synchronize: false })
|
||||
@Index('idx_originalFileName_trigram', { synchronize: false })
|
||||
// For all assets, each originalpath must be unique per user and library
|
||||
export class AssetEntity {
|
||||
@PrimaryGeneratedColumn('uuid')
|
||||
|
@ -159,12 +159,12 @@ export function searchAssetBuilder(
|
||||
builder.andWhere(`${builder.alias}.ownerId IN (:...userIds)`, { userIds: options.userIds });
|
||||
}
|
||||
|
||||
const path = _.pick(options, ['encodedVideoPath', 'originalFileName', 'resizePath', 'webpPath']);
|
||||
const path = _.pick(options, ['encodedVideoPath', 'originalPath', 'resizePath', 'webpPath']);
|
||||
builder.andWhere(_.omitBy(path, _.isUndefined));
|
||||
|
||||
if (options.originalPath) {
|
||||
builder.andWhere(`f_unaccent(${builder.alias}.originalPath) ILIKE f_unaccent(:originalPath)`, {
|
||||
originalPath: `%${options.originalPath}%`,
|
||||
if (options.originalFileName) {
|
||||
builder.andWhere(`f_unaccent(${builder.alias}.originalFileName) ILIKE f_unaccent(:originalFileName)`, {
|
||||
originalFileName: `%${options.originalFileName}%`,
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -3,12 +3,12 @@ import { MigrationInterface, QueryRunner } from 'typeorm';
|
||||
export class AddAssetOriginalPathTrigramIndex1709608140355 implements MigrationInterface {
|
||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`
|
||||
CREATE INDEX idx_originalpath_trigram
|
||||
CREATE INDEX idx_originalFileName_trigram
|
||||
ON assets
|
||||
USING gin (f_unaccent("originalPath") gin_trgm_ops)`);
|
||||
USING gin (f_unaccent("originalFileName") gin_trgm_ops)`);
|
||||
}
|
||||
|
||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`DROP INDEX "idx_originalpath_trigram"`);
|
||||
await queryRunner.query(`DROP INDEX "idx_originalFileName_trigram"`);
|
||||
}
|
||||
}
|
||||
|
@ -94,7 +94,7 @@
|
||||
|
||||
let payload: SmartSearchDto | MetadataSearchDto = {
|
||||
query: filter.context || undefined,
|
||||
originalPath: filter.filename,
|
||||
originalFileName: filter.filename,
|
||||
country: filter.location.country,
|
||||
state: filter.location.state,
|
||||
city: filter.location.city,
|
||||
|
@ -173,7 +173,7 @@
|
||||
make: 'Camera brand',
|
||||
model: 'Camera model',
|
||||
personIds: 'People',
|
||||
originalPath: 'File name',
|
||||
originalFileName: 'File name',
|
||||
};
|
||||
return keyMap[key] || key;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user