[quicksearch] no exact match on file #404

Closed
opened 2026-10-04 23:56:48 +02:00 by adam · 9 comments
Owner

I wonder why we can't perform the same REGEXP pattern on file (compared to name/comment):

SELECT
    id
  from images i
  WHERE (CONVERT(file, CHAR) LIKE '%eau%' OR name REGEXP '[[:<:]]eau[[:>:]]')
;

Here we perform an exact match on name (perfect) but not on file :-/ If the user has filenames which describe the photo, it becomes impossible to perform an exact match.

I wonder why we can't perform the same REGEXP pattern on file (compared to name/comment): ``` SELECT id from images i WHERE (CONVERT(file, CHAR) LIKE '%eau%' OR name REGEXP '[[:<:]]eau[[:>:]]') ; ``` Here we perform an exact match on name (perfect) but not on file :-/ If the user has filenames which describe the photo, it becomes impossible to perform an exact match. <!-- github-sync-id:135358595 -->
adam closed this issue 2026-10-04 23:56:48 +02:00
Author
Owner

My initial thought was that name is plain natural language while file does
not have spaces... But we can change that. Should test if - and _ are
considered word boundaries by MySQL regex
On Feb 22, 2016 10:12, "Pierrick Le Gall" notifications@github.com wrote:

I wonder why we can't perform the same REGEXP pattern on file (compared to
name/comment):

SELECT
id
from images i
WHERE (CONVERT(file, CHAR) LIKE '%eau%' OR name REGEXP ':<:eau:>:')
;

Here we perform an exact match on name (perfect) but not on file :-/ If
the user has filenames which describe the photo, it becomes impossible to
perform an exact match.

—
Reply to this email directly or view it on GitHub
https://github.com/Piwigo/Piwigo/issues/422.

My initial thought was that name is plain natural language while file does not have spaces... But we can change that. Should test if - and _ are considered word boundaries by MySQL regex On Feb 22, 2016 10:12, "Pierrick Le Gall" notifications@github.com wrote: > I wonder why we can't perform the same REGEXP pattern on file (compared to > name/comment): > > SELECT > id > from images i > WHERE (CONVERT(file, CHAR) LIKE '%eau%' OR name REGEXP '[[:<:]]eau[[:>:]]') > ; > > Here we perform an exact match on name (perfect) but not on file :-/ If > the user has filenames which describe the photo, it becomes impossible to > perform an exact match. > > — > Reply to this email directly or view it on GitHub > https://github.com/Piwigo/Piwigo/issues/422. <!-- github-comment-id:187085950 -->
Author
Owner

Actually, file names have no space only when added files with FTP+sync. Many many file names have spaces and "any" char when added with web API.

Actually, file names have no space only when added files with FTP+sync. Many many file names have spaces and "any" char when added with web API. <!-- github-comment-id:187087657 -->
Author
Owner

I'll try to find a regexp that works in all cases probably something like:
([[:<:]]|_)eau([[:>:]]|_)

I'll try to find a regexp that works in all cases probably something like: `([[:<:]]|_)eau([[:>:]]|_)` <!-- github-comment-id:187091311 -->
Author
Owner

and I don't understand why the help says you have to do {"word"} for an exact match because {word} already works fine. Actually, if you "don't" want to perform an exact match you have to search {*word*}.

and I don't understand why the help says you have to do {"word"} for an exact match because {word} already works fine. Actually, if you "don't" want to perform an exact match you have to search `{*word*}`. <!-- github-comment-id:187106768 -->
Author
Owner

@plegall, I don't get your last comment. Are you referring to quick search help ?

Use quotes to search for an exact word or phrase. ""george washington""

@plegall, I don't get your last comment. Are you referring to quick search help ? > Use quotes to search for an exact word or phrase. ""george washington"" <!-- github-comment-id:187116443 -->
Author
Owner

also note that word will match words. while "word" will not match words.

also note that **word** will match **words**. while **"word"** will not match **words**. <!-- github-comment-id:187116918 -->
Author
Owner

Yes, I'm referring to quick search help. If I search {word} (without taking file name into account), Piwigo won't find "wording" or "sword". If I want to get those results I have to search {*word*} (and I think it's a good default behavior, even if it's not the behavior of advanced search). This is why I wonder why there is an "exact match" syntax. I guess it's only for a "phrase" (several words) and not for a single word.

Yes, I'm referring to quick search help. If I search {word} (without taking file name into account), Piwigo won't find "wording" or "sword". If I want to get those results I have to search `{*word*}` (and I think it's a good default behavior, even if it's not the behavior of advanced search). This is why I wonder why there is an "exact match" syntax. I guess it's only for a "phrase" (several words) and not for a single word. <!-- github-comment-id:187149091 -->
Author
Owner

Exact match is primarily for a phrase but also to avoid looking for inflections of a single word (inflections work only in english/french). If your language is french, searches for eau should also match eaux unless eau is quoted. In english singular/plural forms are recognized and also -ing -er (eg. search for runner will also match running or runners)

Exact match is primarily for a phrase but also to avoid looking for inflections of a single word (inflections work only in english/french). If your language is french, searches for **eau** should also match **eaux** unless eau is quoted. In english singular/plural forms are recognized and also -ing -er (eg. search for **runner** will also match **running** or **runners**) <!-- github-comment-id:187161825 -->
Author
Owner

OK, I had understood that when debugging the SQL query, but I don't think it's really "expected". Anyway, I think the current algorithm is fine (excepted for file name) and maybe we should just say that "exact match with surrounding quotes" is for phrases.

OK, I had understood that when debugging the SQL query, but I don't think it's really "expected". Anyway, I think the current algorithm is fine (excepted for file name) and maybe we should just say that "exact match with surrounding quotes" is for phrases. <!-- github-comment-id:187171301 -->
Sign in to join this conversation.
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: adam/Piwigo#404