1
0
mirror of https://github.com/immich-app/immich.git synced 2024-12-25 10:43:13 +02:00
immich/server
Sushain Cherivirala 7fc1954e2a
fix(server): add filename search (#6394)
Fixes https://github.com/immich-app/immich/issues/5982.

There are basically three options:

1. Search `originalFileName` by dropping a file extension from the query
(if present). Lower fidelity but very easy - just a standard index &
equality.
2. Search `originalPath` by adding an index on `reverse(originalPath)`
and using `starts_with(reverse(query) + "/", reverse(originalPath)`. A
weird index & query but high fidelity.
3. Add a new generated column called `originalFileNameWithExtension` or
something. More storage, kinda jank.

TBH, I think (1) is good enough and easy to make better in the future.
For example, if I search "DSC_4242.jpg", I don't really think it matters
if "DSC_4242.mov" also shows up.

edit: There's a fourth approach that we discussed a bit in Discord and
decided we could switch to it in the future: using a GIN. The minor
issue is that Postgres doesn't tokenize paths in a useful (they're a
single token and it won't match against partial components). We can
solve that by tokenizing it ourselves. For example:

```
immich=# with vecs as (select to_tsvector('simple', array_to_string(string_to_array('upload/library/sushain/2015/2015-08-09/IMG_275.JPG', '/'), ' ')) as vec)  select * from vecs where vec @@ phraseto_tsquery('simple', array_to_string(string_to_array('library/sushain', '/'), ' '));
                                      vec
-------------------------------------------------------------------------------
 '-08':6 '-09':7 '2015':4,5 'img_275.jpg':8 'library':2 'sushain':3 'upload':1
(1 row)
```

The query is also tokenized with the 'split-by-slash-join-with-space'
strategy. This strategy results in `IMG_275.JPG`, `2015`, `sushain` and
`library/sushain` matching. But, `08` and `IMG_275` do not match. The
former is because the token is `-08` and the latter because the
`img_275.jpg` token is matched against exactly.
2024-01-15 14:40:28 -06:00
..
bin refactor: open api (#6334) 2024-01-12 07:36:27 -05:00
e2e fix(server): add filename search (#6394) 2024-01-15 14:40:28 -06:00
resources feat: postgres reverse geocoding (#5301) 2023-11-25 18:53:30 +00:00
src fix(server): add filename search (#6394) 2024-01-15 14:40:28 -06:00
test feat(server, web): quotas (#4471) 2024-01-12 19:43:36 -05:00
.eslintrc.js chore(server): curly braces (#5361) 2023-11-28 15:09:20 -05:00
.gitignore feat(web): re-add open graph tags for public share links (#5635) 2023-12-11 13:37:47 -06:00
.prettierignore refactor: open api (#6334) 2024-01-12 07:36:27 -05:00
.prettierrc fix(server): lint import order (#3974) 2023-09-04 21:45:59 +02:00
Dockerfile refactor: open api (#6334) 2024-01-12 07:36:27 -05:00
nest-cli.json refactor(server)*: tsconfigs (#2689) 2023-06-08 10:01:07 -05:00
openapitools.json chore(server): update openapi (#2205) 2023-04-08 21:26:09 -05:00
package-lock.json fix(deps): update dependency geo-tz to v8 (#6388) 2024-01-15 08:27:59 -05:00
package.json fix(deps): update dependency geo-tz to v8 (#6388) 2024-01-15 08:27:59 -05:00
start-microservices.sh fix: shebangs (#3643) 2023-08-16 22:50:01 -05:00
start-server.sh fix: shebangs (#3643) 2023-08-16 22:50:01 -05:00
start.sh fix(server): immich command (#5408) 2023-11-30 14:59:47 -06:00
tsconfig.build.json fix: exclude e2e format (#3250) 2023-07-13 21:41:16 -05:00
tsconfig.json fix(server): better fix for the OAuth Discovery errors (#4695) 2023-10-30 13:22:30 -04:00