mirror of
https://github.com/immich-app/immich.git
synced 2024-12-27 10:58:13 +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_day_of_month', { synchronize: false })
|
||||||
@Index('IDX_month', { synchronize: false })
|
@Index('IDX_month', { synchronize: false })
|
||||||
@Index('IDX_originalPath_libraryId', ['originalPath', 'libraryId'])
|
@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
|
// For all assets, each originalpath must be unique per user and library
|
||||||
export class AssetEntity {
|
export class AssetEntity {
|
||||||
@PrimaryGeneratedColumn('uuid')
|
@PrimaryGeneratedColumn('uuid')
|
||||||
|
@ -159,12 +159,12 @@ export function searchAssetBuilder(
|
|||||||
builder.andWhere(`${builder.alias}.ownerId IN (:...userIds)`, { userIds: options.userIds });
|
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));
|
builder.andWhere(_.omitBy(path, _.isUndefined));
|
||||||
|
|
||||||
if (options.originalPath) {
|
if (options.originalFileName) {
|
||||||
builder.andWhere(`f_unaccent(${builder.alias}.originalPath) ILIKE f_unaccent(:originalPath)`, {
|
builder.andWhere(`f_unaccent(${builder.alias}.originalFileName) ILIKE f_unaccent(:originalFileName)`, {
|
||||||
originalPath: `%${options.originalPath}%`,
|
originalFileName: `%${options.originalFileName}%`,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,12 +3,12 @@ import { MigrationInterface, QueryRunner } from 'typeorm';
|
|||||||
export class AddAssetOriginalPathTrigramIndex1709608140355 implements MigrationInterface {
|
export class AddAssetOriginalPathTrigramIndex1709608140355 implements MigrationInterface {
|
||||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||||
await queryRunner.query(`
|
await queryRunner.query(`
|
||||||
CREATE INDEX idx_originalpath_trigram
|
CREATE INDEX idx_originalFileName_trigram
|
||||||
ON assets
|
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> {
|
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 = {
|
let payload: SmartSearchDto | MetadataSearchDto = {
|
||||||
query: filter.context || undefined,
|
query: filter.context || undefined,
|
||||||
originalPath: filter.filename,
|
originalFileName: filter.filename,
|
||||||
country: filter.location.country,
|
country: filter.location.country,
|
||||||
state: filter.location.state,
|
state: filter.location.state,
|
||||||
city: filter.location.city,
|
city: filter.location.city,
|
||||||
|
@ -173,7 +173,7 @@
|
|||||||
make: 'Camera brand',
|
make: 'Camera brand',
|
||||||
model: 'Camera model',
|
model: 'Camera model',
|
||||||
personIds: 'People',
|
personIds: 'People',
|
||||||
originalPath: 'File name',
|
originalFileName: 'File name',
|
||||||
};
|
};
|
||||||
return keyMap[key] || key;
|
return keyMap[key] || key;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user