[4.0] com_finder: add search statistics#20681
Conversation
| COM_FINDER_ITEM_X_ONLY="%s Only" | ||
| COM_FINDER_ITEMS="Content" | ||
| COM_FINDER_LOGGING_DISABLED="Gathering statistics disabled. Enable it in the Options." | ||
| COM_FINDER_LOGGING_ENABLED="Gathering statistics enabled" |
There was a problem hiding this comment.
This should have a period at the end - however I am not sure we even need to display this notice
There was a problem hiding this comment.
Fixed. Since search logging could be pretty resource intensive, it doesn't seem like the worst idea to have that notice. We have this in the current com_search statistics, too. However I'm open for change requests. Should I remove this notice?
…4finder_log # Conflicts: # administrator/components/com_finder/sql/install.postgresql.sql # administrator/components/com_finder/sql/uninstall.mysql.sql # administrator/components/com_finder/sql/uninstall.postgresql.sql
|
I got this on the frontend:
|
| { | ||
| $canDo = $this->canDo; | ||
|
|
||
| ToolbarHelper::title(\JText::_('COM_FINDER_MANAGER_SEARCHES'), 'search'); |
There was a problem hiding this comment.
I see you use JText for all strings. Why not use the new Text class?
There was a problem hiding this comment.
It honestly doesn't matter either way right now if namespaced or aliased global classes are used.
There was a problem hiding this comment.
Yes I know, that is why I ask. Thank for answer
|
This is mainly code copied from current com_search. Is it required that all of this is updated to the latest code or can we keep it the way it is right now and merge this? |
|
I know you wrote, you will work more in this in other PR, but you can update the code with this move, and then work more easily in the update you want to do. No problem, if you prefer to wait. |
|
@carlitorweb Please make sure that you have the latest version of 4.0-dev before applying this PR. It seems as if you don't have the latest updates that I did to com_finder lately. |
|
Yes, I have the last version of 4.0-dev branch. No problem with that. |
|
By the way, now I have the option working well, in the admin side. No more the message I had before. Sorry for this, was a mistake when I merge you PR |
|
Sorry, a typo-fix was not commited. Fixed that one. Please test again. 😉 |
|
Also, every time you enter in the |
| <field | ||
| name="search" | ||
| type="text" | ||
| label="COM_FINDER_SEARCH_IN_PHRASE" |
There was a problem hiding this comment.
Missing language string. label and description have the same constant.
|
@carlitorweb Since the statistics gathering can potentially create a lot of entries in the table, there should be a notice either way, both when it is on and when it is off. That was at least the reasoning for this in the logging in com_search. @Quy fixed. |
|
@carlitorweb I can not confirm that error message. Please don't use the pulltester for this. |
|
Thank @Hackwar . Yes, I just end the test without patchtester and no get the warning. Sorry for boring with this, I just start to get the idea when use or not the patchtester |
|
I have tested this item ✅ successfully on 8ed03d7 This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/20681. |
|
Fix year in filename |
| /** | ||
| * Methods supporting a list of search terms. | ||
| * | ||
| * @since __DEPLOYED_VERSION__ |
| * @param MVCFactoryInterface $factory The factory. | ||
| * | ||
| * @see \Joomla\CMS\MVC\Model\BaseDatabaseModel | ||
| * @since 4.0 |
There was a problem hiding this comment.
__DEPLOY_VERSION__ Repeat below.
|
|
||
| // Log the search | ||
| SearchHelper::logSearch($this->query->input, 'com_finder'); | ||
| FinderHelper::logSearch($this->query, count($this->total)); |
There was a problem hiding this comment.
$this->total is an integer thus the warning message below:
Warning: count(): Parameter must be an array or an object that implements Countable in \components\com_finder\View\Search\HtmlView.php on line 163
|
@Quy fixed the bugs. |
|
Then, my local environment no was so crazy when I had this warning ;) . |
|
I have tested this item ✅ successfully on 780205e This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/20681. |
…4finder_log # Conflicts: # components/com_finder/View/Search/HtmlView.php
|
I have tested this item ✅ successfully on 7eeab91 This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/20681. |
|
@carlitorweb can you please retest? |
|
I have tested this item ✅ successfully on 7eeab91 This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/20681. |
|
Ready to Commit after two successful tests. |
| `hits` INT(11) NOT NULL DEFAULT '1', | ||
| `results` INT(11) NOT NULL DEFAULT '0', | ||
| UNIQUE INDEX `md5sum` (`md5sum`), | ||
| INDEX `searchterm` (`searchterm`) |
There was a problem hiding this comment.
Index has to be limited to the first 191 characters. See issue #21235



Smart Search right now has no own logging, but instead uses the crappy logging of com_search, which itself is from Mambo times... The logging of com_search only logs the search term and the number of times that it was searched for and while there is an idea that it should log the statistics separately for both com_search and com_finder, it can't even distinguish between the two...
Anyway, this PR is based on issue #17437 and for now immitates the logging of com_search. In the component configuration I renamed the option to enable the logging to something that is a bit more descriptive. Then I added a new table for the logging data and in that table we now store the search term, the query object, the number of times this specific search was executed (including the filter settings), the number of given results for this and an md5sum to compare searches easily.
In the backend we have a new view, copied over from com_search mainly and updated to com_finder, that displays the statistics. At the top we have a button to reset these stats.
This PR implements the statistics that are part of com_search in com_finder, so that we can drop com_search and I would call this PR ready for now. In a second step, I would like to improve the FinderIndexerQuery class and the display of the stats to also display the filters of that search query and the language. But to be honest, I don't know how to display this nicely right now and I wanted to get this PR out there. So that would be part of another PR.
@alikon Can you check if I did the Postgres queries right? I didn't test those and just modeled them after the other queries that we have so far.
This removes a blocker for #20637