bug PR-5.4-dev Pending

User tests: Successful: Unsuccessful:

avatar SRV-KILLER09
SRV-KILLER09
25 Mar 2026

Pull Request resolves #47447

  • I have read the Generative AI policy, and this contribution is either created without AI assistance or complies with the policy and GNU/GPL 2 or later.

Summary of Changes

This PR fixes an issue in the Finder indexer where duplicate term entries could cause the indexing process to fail.

The INSERT query in administrator/components/com_finder/src/Indexer/Indexer.php has been updated to prevent duplicate term errors. A LEFT JOIN is added to the #__finder_terms table along with an IS NULL condition, ensuring that only terms that don’t already exist are inserted.

Changed file:

  • administrator/components/com_finder/src/Indexer/Indexer.php — updated INSERT query to safely handle duplicates

Testing Instructions

  1. Create multiple articles with similar normalized terms (for example, "Café" and "Cafe", which normalize to the same value).
  2. Assign them to the same language.
  3. Go to Components -> Finder (Search) -> Indexer.
  4. Click Start Indexing.
  5. Confirm that the indexing completes without errors.
  6. Verify that all articles are searchable via Finder on the frontend.

Before this fix:
Indexing stops with the error:
Duplicate entry X-* for key idx_term_language

After this fix:
Indexing completes successfully, and duplicate terms are handled without errors.

Actual Result (Before this PR)

When content includes terms that normalize to the same value (such as accented vs. non-accented versions), the Finder indexer attempts to insert duplicate entries into the #__finder_terms table.

This causes a database error:
Duplicate entry X-* for key idx_term_language

As a result, the indexing process stops entirely, and the search index remains incomplete.

Expected Result (After this PR)

Indexing completes successfully even when duplicate normalized terms are present.

  • The query now checks for existing terms using a LEFT JOIN.
  • Only non-existing terms are inserted (IS NULL condition).
  • Duplicate key errors are avoided.
  • Indexing continues without interruption.
  • All content is properly indexed and searchable.

Result: More reliable and error-free indexing across supported databases (MySQL, PostgreSQL, SQL Server).

Link to Documentation

Please select:

  • Documentation link for guide.joomla.org:

  • No documentation changes needed for guide.joomla.org

  • Pull Request link for manual.joomla.org:

  • No documentation changes needed for manual.joomla.org

avatar SRV-KILLER09 SRV-KILLER09 - open - 25 Mar 2026
avatar SRV-KILLER09 SRV-KILLER09 - change - 25 Mar 2026
Status New Pending
avatar joomla-cms-bot joomla-cms-bot - change - 25 Mar 2026
Category Administration com_finder
avatar muhme muhme - change - 27 Mar 2026
Title
Fix duplicate term index error in com_finder by excluding existing terms
[5.4] Fix duplicate term index error in com_finder by excluding existing terms
avatar muhme muhme - edited - 27 Mar 2026
avatar LadySolveig
LadySolveig - comment - 27 Mar 2026

Thanks for the PR, could you imagine to make a new one for 6.2 with your fix and additional refactoring for the DB query stuff like here (not tested):

        $select = $db->getQuery(true)
            ->select([
                'ta.term',
                'ta.stem',
                'ta.common',
                'ta.phrase',
                'ta.term_weight',
                'SOUNDEX(ta.term) AS soundex',
                'ta.language',
            ])
            ->from($db->quoteName('#__finder_tokens_aggregate', 'ta'))
            ->leftJoin($db->quoteName('#__finder_terms', 'ft'), 'ft.term = ta.term AND ft.language = ta.language')
            ->where($db->quoteName('ta.term_id') . ' = :termid')
            ->andWhere('ft.term_id IS NULL')
            ->group($db->quoteName('ta.term') . ', ' . $db->quoteName('ta.stem') . ', ' . $db->quoteName('ta.common') . ', ' . $db->quoteName('ta.phrase') . ', ' . $db->quoteName('ta.term_weight') . ', SOUNDEX(ta.term), ' . $db->quoteName('ta.language'));

        $insert = $db->getQuery(true)
            ->insert($db->quoteName('#__finder_terms'))
            ->columns([
                $db->quoteName('term'),
                $db->quoteName('stem'),
                $db->quoteName('common'),
                $db->quoteName('phrase'),
                $db->quoteName('weight'),
                $db->quoteName('soundex'),
                $db->quoteName('language'),
            ])
            ->select($select);

        $select->bind(':termid', 0, ParameterType::INTEGER);

        $db->setQuery($insert);
        $db->execute();

It would be a good time to do it now that we're already working on it.

avatar ThomasFinnern ThomasFinnern - test_item - 27 Mar 2026 - Tested unsuccessfully
avatar ThomasFinnern
ThomasFinnern - comment - 27 Mar 2026

I have tested this item 🔴 unsuccessfully on 9c93e82

I can not reproduce the issue

  1. Activated multilanguage examples
  2. created 2 articles with different versions of Resumé and Resume

No error on indexing


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/47472.

avatar SRV-KILLER09
SRV-KILLER09 - comment - 1 Apr 2026

Hii! Thanks for the review feedback..!! and As requested, I've opened a new PR (#47531) targeting 6.2-dev with the query-builder refactor and regression test coverage. Thankyou!

avatar SRV-KILLER09 SRV-KILLER09 - change - 1 Apr 2026
Status Pending Closed
Closed_Date 0000-00-00 00:00:00 2026-04-01 19:16:36
Closed_By SRV-KILLER09
Labels Added: bug PR-5.4-dev
avatar SRV-KILLER09 SRV-KILLER09 - close - 1 Apr 2026

Add a Comment

Login with GitHub to post a comment