Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: search by description #15818

Merged
merged 6 commits into from
Feb 2, 2025
Merged

feat: search by description #15818

merged 6 commits into from
Feb 2, 2025

Conversation

alextran1502
Copy link
Contributor

@alextran1502 alextran1502 commented Jan 31, 2025

Add an option to search by description using postgresql text search

image

TODO

  • Mobile integration

Copy link
Contributor

@jrasm91 jrasm91 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks ok. It might be nicer to have a drop-down instead of a radio group

@@ -396,6 +396,9 @@ export function searchAssetBuilder(kysely: Kysely<DB>, options: AssetSearchBuild
sql`'%' || f_unaccent(${options.originalFileName}) || '%'`,
),
)
.$if(!!options.description, (qb) =>
qb.innerJoin('exif', 'assets.id', 'exif.assetId').where('exif.description', 'ilike', `%${options.description}%`),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably want to escape the value being passed in in case there's a % in the string? Otherwise searching for 100% will return descriptions containing 100.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this happens automatically by the library

@mertalev
Copy link
Contributor

mertalev commented Feb 2, 2025

There should be an f_unaccent'd trigram index for this and the query should use f_unaccent, like for the filename search.

@alextran1502 alextran1502 merged commit 4efacfb into main Feb 2, 2025
37 checks passed
@alextran1502 alextran1502 deleted the search-by-description branch February 2, 2025 21:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants