[search] search by word in album names does not work #1688

Closed
opened 2026-10-05 00:53:04 +02:00 by adam · 0 comments
Owner

I have an album named "great britain". If I search for "great" in the "search by word" filter, it should find all photos belonging to this album. It does not. Indeed the SQL query generated is:

SELECT DISTINCT(id)
  FROM piwigo_images i
    INNER JOIN piwigo_image_category AS ic ON id = ic.image_id
  WHERE (
         (file LIKE '%great%'
          OR name LIKE '%great%'
          OR comment LIKE '%great%')
         AND
         category_id IN (1))
  ORDER BY date_available DESC, file ASC, id ASC

We see that album 1 matches the "great" word in its name (or description). The SQL queries says "it must belong to this album + its filename OR title OR description must match the word "great" also. We never occurs in my data sample. The category_id IN (...) is not correctly placed in the SQL query. We should have this instead:

SELECT DISTINCT(id)
  FROM piwigo_images i
    INNER JOIN piwigo_image_category AS ic ON id = ic.image_id
  WHERE (
         (file LIKE '%great%'
          OR name LIKE '%great%'
          OR comment LIKE '%great%'
          OR category_id IN (1))
         )
  ORDER BY date_available DESC, file ASC, id ASC
I have an album named "great britain". If I search for "great" in the "search by word" filter, it should find all photos belonging to this album. It does not. Indeed the SQL query generated is: ``` SELECT DISTINCT(id) FROM piwigo_images i INNER JOIN piwigo_image_category AS ic ON id = ic.image_id WHERE ( (file LIKE '%great%' OR name LIKE '%great%' OR comment LIKE '%great%') AND category_id IN (1)) ORDER BY date_available DESC, file ASC, id ASC ``` We see that album 1 matches the "great" word in its name (or description). The SQL queries says "it must belong to this album + its filename OR title OR description must match the word "great" also. We never occurs in my data sample. The `category_id IN (...)` is not correctly placed in the SQL query. We should have this instead: ``` SELECT DISTINCT(id) FROM piwigo_images i INNER JOIN piwigo_image_category AS ic ON id = ic.image_id WHERE ( (file LIKE '%great%' OR name LIKE '%great%' OR comment LIKE '%great%' OR category_id IN (1)) ) ORDER BY date_available DESC, file ASC, id ASC ``` <!-- github-sync-id:1781085133 -->
adam closed this issue 2026-10-05 00:53:04 +02:00
Sign in to join this conversation.
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: adam/Piwigo#1688