Search page should show “Article A” and “Article B” since both contain the word “article” and both of their categories are selected in the search filter.
Search page shows “No Results Found”.
Joomla 4.1.5
PHP 7.4
It appears the issue may be due to either one or both of the following files:
/components/com_finder/src/Model/SearchModel.php
Potentially within populateState() and getListQuery() of SearchModel.php
/administrator/components/com_finder/src/Indexer/Query.php
Potentially within processStaticTaxonomy() for Query.php
The design of the taxonomy database table may be playing a role as well.
I imagine the majority of joomla sites have a decent mix of root level parent categories and child categories. As it is now, the search filters are completely broken for those that use them with child categories. I think most would appreciate it very much if this could be fixed as soon as possible.
Labels |
Added:
No Code Attached Yet
|
Title |
|
Title |
|
Indeed, the section of code you've described within getListQuery() inside /components/com_finder/src/Model/SearchModel.php is one potential location where a fix could be inserted.
We can dive deeper by looking at what exactly that section of code is iterating through. Namely, it is $this->searchquery->filters. Following the simple example in the first post of this issue thread, if we do some debugging and output this variable, we see the following:
array(2) {
["Category"]=> array(1) {
["Parent Category"]=> int(10)
}
["Parent Category"]=> array(1) {
["Child Category"]=> int(11)
}
}
As the description of that section of code goes (which you have also mentioned):
"We have to join the taxonomy map table for each group so that we can use AND clauses across groups. Within each group there can be an array of values that will use OR clauses."
Knowing this, clearly something is wrong. Due to the way the array is structured, the code interprets "Child Category" to be in its own group and uses an AND clause here which means the code is trying to find items within both "Parent Category" and "Child Category", which is impossible since an item can only be in a single category, hence the lack of results that show up.
So a fix could manifest itself within the code you mentioned to better interpret this array, but I'm not sure that that would be a robust solution. I think a better one may be to adjust how the array is structured so that the existing code works. (for example, in this very specific example, "Child Category" should be grouped under "Category" along with "Parent Category")
Within SearchModel.php, we then see that $this->searchquery->filters is first set within the populateState() function.
If we continue diving deeper, we then see that populateState() is setting $this->searchquery by using /administrator/components/com_finder/src/Indexer/Query.php. Specifically, the constructor of Query.php is using the processStaticTaxonomy() function to set $this->filters. In other words, $this->searchquery->filters used by SearchModel.php seems to ultimately be set by processStaticTaxonomy() within Query.php.
The way that the function processStaticTaxonomy() works is intertwined with the design of the taxonomy table in the database.
So there are many steps within this process where code could be adjusted to produce a fix, but I'm not sure how deep the Joomla team wants to go with changes. Presumably, the change should be a general fix that works in all scenarios.
(Although I'm somewhat able to decipher what is going on here, I'm not really familiar with the Joomla codebase and how everything is interconnected, so I'm not comfortable proposing an explicit list of changes.)
Anyway, can someone add the "bug" label (and any other relevant ones) to this issue? I see it hasn't been added on yet.
Labels |
Added:
bug
|
Thanks @crimle for your feedback - good to hear that it works for you! But be careful - my fix is not working in general.
For example it is working if you need to do a search for articles throughout several categories - parent or child or both. So I only select these categories in the filter - and nothing else, not "type", not "author". Otherwise the filter does not work any more (because it will find ALL articles if selected "article" as type e.g. due to the OR in the query).
So somebody has to do the fine grading of the Joomla programming work as @kwellesleyedu correctly said ...
In the filter I am using
Type = Categories and Articles
Author = none
Category = those related to the sport in question
For my needs it works and I am happy.
Kind regards
Chris
Unfortunatley I have to ask a follow up question to @crimle: did you try to search for an author's name and would you confirm that the finder does NOT provide articles created or modified by this author? As in your filter you also don't want to look for author's name, right?
Because on my site there seems to be a second bug in the finder. First I thougt it might be related with my bugfix above but it isn't.
Here is a five year old bugfix which still seems to work - at least for me:
https://joomla.stackexchange.com/questions/19506/smart-search-exclude-search-articles-by-author-name
Thank you once again.
Using Smart Search (without Filter)
Searching for author's name lists any article that has ever been created by this user. Which is completely pointless.
I opened «Content Maps» and disabled the author in question. This has no effect to the search results. Any article that has ever been created by this user are still listed.
You may also disable the whole parent item «Author». There is still no effect to the search results.
Using Smart Search (with a user defined filter)
In this filter I did NOT select the author.
Searching for author's name does NOT list articles that have been created by this user. This is working as expected.
Using Smart Search (with a user defined filter) after applying the bugfix you mentionned above
Searching for author's name lists any article that has ever been created by this user. Which is NOT working as expected.
So, sadly enough, as much as I appreciate your bugfix contribution, I must admit that it works partially only. But maybe this error would not exist if the basic issue with Smart Search (Content Maps > Disabled Authors) was solved.
Kind regards
Chris
Thank you, Chris, for coming back with this detailed testing!
So it just reaffirms "my fix is not working in general"...
For my special needs it is working with or without setting a filter (which selects some categories, nothing else), but only with adding the mentioned 2 bugfixes in core files. This is of course not the way it should be. :(
For those with German language knowledge - I found the author's name issue also described in the german forum
So let's hope that there will come a smart developer for fixing the smart search of Joomla 4.
Apart from these problems the smart search is SO much better than the old search extension... I really appreciate all the programming work for this.
Hi there,
Can I confirm that this Forum post is related to the same problem?
https://forum.joomla.org/viewtopic.php?f=808&t=995243
You think I can use the fix above too?
Thanks,
Liz
Yes, it appears you are describing the same problem.
The code change brought up by @pixelhexe is not a general fix and only works in a very specific situation so you need to be extremely careful if you want to try it out.
I think a more involved design change may be needed for a fully robust solution. (as opposed to just changing some of the outer most code)
That said, I think we're all just waiting on the Joomla team to address this issue. No idea when they'll get around to this.
Thanks for your quick reply, I will keep following this post then.
There are two others in the forum with the same type of problem.
https://forum.joomla.org/viewtopic.php?f=808&t=995058
https://forum.joomla.org/viewtopic.php?f=808&t=995062
Indeed, I imagine this issue to be affecting a lot of people. It's perfectly natural to organize categories into different levels and is something I presume most partake in to some degree.
Just following up on this. (3 months later now)
I've just tested out the latest Joomla 4.2.5 with PHP on 8.1 and the issue described here still exists. The filters feature of the smart search component is still very broken.
Title |
|
Title |
|
Having the same issue. Can't believe this has been left for 6 months - anything larger than a small website means search filters are basically unusable. Nesting categories is so common.
Can someone from the Joomla team comment on this?
Status | New | ⇒ | Closed |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2023-02-10 12:38:38 |
Closed_By | ⇒ | Hackwar |
I have to confirm this as I just stumbled upon it.
The bug seems indeed to be in the file
in the getListQuery() - more concrete the description says "We have to join the taxonomy map table for each group so that we can use AND clauses across groups. Within each group there can be an array of values that will use OR clauses."
But in the end there are only AND clauses in the HAVING SUM .... clauses of the query.
For my purposes (!!!) I could fix it by adding ", $glue = 'OR'" as follows in the HAVING clause:
my bugfix is:
My purpose is using a search filter to find articles inside several parent and child categories. With my bugfixing I can use this filter, without the fix there are no results as described from kwellesleyedu.
Maybe this would not be a general fix so somebody from the core developers should dive deeper. Thank you!