? Failure

User tests: Successful: Unsuccessful:

avatar chrisdavenport
chrisdavenport
1 Feb 2019

If you write a Smart Search plugin that creates a taxonomy (content map) that includes non-disjoint nodes (shown under "Titles" in the admin UI) then you will sometimes get pages in the search results which have fewer entries than expected. For example, if a page should have 20 results in it, it might only have 19. There are no results missing from the search, but the pagination is a bit off.

All the core content types (eg. Articles, Contacts, etc.) have taxonomies with disjoint nodes so the bug doesn't manifest itself with any of the core components. You'd have to write your own plugin to experience the problem. I'm not going to do that here as I'm hoping that my description of the problem and the simplicity of the solution will suffice.

Suppose you have a database table and you want to write a simple plugin to index its contents. Apart from the usual text entries, you also want to have a taxonomy (content map) called "Flags" which indicate some particular features of some of the items in the table. These flags are not disjoint, so a particular item could have more than one flag associated with it.

In the plugin, the code might look something like this (not real PHP, of course):

if ($item has A)
{
    $item->addTaxonomy('Flags', 'A');
}

if ($item has B)
{
    $item->addTaxonomy('Flags', 'B');
}

The Smart Search indexer can and does correctly handle the case where some items have both A and B. The only problem is that front-end search results pagination is off whenever the page contains an item that has both flags.

In components/com_finder/models/search.php you can see the cause of the problem. The FinderModelSearch::getListQuery method returns duplicate results in this case because the WHERE clause associated with the taxonomy does a WHERE t0.node_id IN (x,y) which logically ORs the x and y nodes, but also results in separate (duplicate) rows for each. However, FinderModelSearch::getResultsData squashes the duplicates out because it does a loadObjectList('link_id'). So if the raw database query returned 20 results, say, after squashing duplicates the page actually returned to the user might contain only 19 (or fewer).

The fix is simply to avoid getting duplicates in the first place. Simply add a DISTINCT to the SELECT in getListQuery.

avatar chrisdavenport chrisdavenport - open - 1 Feb 2019
avatar chrisdavenport chrisdavenport - change - 1 Feb 2019
Status New Pending
avatar joomla-cms-bot joomla-cms-bot - change - 1 Feb 2019
Category Front End com_finder
avatar franz-wohlkoenig franz-wohlkoenig - change - 19 Apr 2019
Title
[Smart Search] Pagination error when taxonomy contains non-disjoint nodes
Pagination error when taxonomy contains non-disjoint nodes
avatar franz-wohlkoenig franz-wohlkoenig - change - 19 Apr 2019
Title
[Smart Search] Pagination error when taxonomy contains non-disjoint nodes
Pagination error when taxonomy contains non-disjoint nodes
avatar franz-wohlkoenig franz-wohlkoenig - edited - 19 Apr 2019
avatar franz-wohlkoenig
franz-wohlkoenig - comment - 24 Apr 2019

can you please give Instructions how to test?

avatar ghost
ghost - comment - 20 Jul 2019

closed due the lack of Response.

avatar franz-wohlkoenig franz-wohlkoenig - close - 20 Jul 2019
avatar franz-wohlkoenig franz-wohlkoenig - change - 20 Jul 2019
Status Pending Closed
Closed_Date 0000-00-00 00:00:00 2019-07-20 08:16:10
Closed_By franz-wohlkoenig
avatar SharkyKZ SharkyKZ - change - 12 Aug 2019
Status Closed Pending
Closed_Date 2019-07-20 08:16:10
Closed_By franz-wohlkoenig
avatar joomla-cms-bot joomla-cms-bot - change - 12 Aug 2019
Status Pending New
Closed_Date 0000-00-00 00:00:00
avatar joomla-cms-bot joomla-cms-bot - change - 12 Aug 2019
Status New Pending
avatar joomla-cms-bot joomla-cms-bot - reopen - 12 Aug 2019
avatar joomla-cms-bot
joomla-cms-bot - comment - 12 Aug 2019
avatar Hackwar
Hackwar - comment - 5 Apr 2022

This has been fixed in 4.0 and with the way all of this is done in 3.x, I don't see how to fix this there. So this should be closed.

avatar laoneo
laoneo - comment - 5 Apr 2022

@chrisdavenport thanks for your contribution. Perhaps you want to have a look on the refactored smart search component in Joomla 4, we always need some helping hands.

avatar laoneo laoneo - close - 5 Apr 2022
avatar laoneo laoneo - change - 5 Apr 2022
Status Pending Closed
Closed_Date 0000-00-00 00:00:00 2022-04-05 08:37:43
Closed_By laoneo
Labels Added: ?
Removed: ?

Add a Comment

Login with GitHub to post a comment