User tests: Successful: Unsuccessful:
Pull Request for Issue #12829. Re-do of #36747.
This PR implements indexing of the custom fields for a component. This is controlled on a per field basis, where you can select if the content should be just added to the search index or handled as a taxonomy or both or actually none of the above. You can then implement this feature for your respective finder plugin with a single line of code.
Each custom field has a new option in its edit screen where you can select how the indexer should treat this field. The finder plugin then has to call Helper::addCustomFields($item, 'context');
and the rest is just magic. ;)
Right now this is implemented for com_content and com_contacts.
This is a re-do of #36747, which had to be reverted due to issues when indexing via CLI. This issue should be solved when #38585 and #39550 are merged.
The documentation needs to be amended to contain how to implement this feature for third party finder plugins.
Status | New | ⇒ | Pending |
Category | ⇒ | Administration com_fields com_finder Language & Strings Front End Plugins |
Labels |
Added:
Language Change
PR-4.3-dev
|
Labels |
Added:
Documentation Required
|
Happy to test this also when it's ready!
I would love to claim that this is ready to test, but it turns out I overlooked something and I don't know how to solve it right now. Yes, this code properly indexes the custom fields and this is all working fine, however the content is not updated or modified when the definition of the custom field is changed. So when you unpublish, delete or change the access to a custom field after indexing, that is not updated in the index. There also is no easy solution to make this automatic. My current solution would be to add warning messages if the access, publish or smart search setting for a custom field is changed and then to display those after saving.
So after some considerations there is no feasible solution to update the index automatically when a field is unpublished or the access is changed. The next best thing would be to display a message after saving that the smart search index might need updating, which I've added for the cases when a field has its access or publish state changed or when it has been added or removed as to-be-indexed field. Thus: We are ready to test (and merge) this feature.
Can index be triggered automatically after doing so? How did the search component handle this?
well you can use console command php cli/joomla.php finder:indexer
maybe wtih cron
or we should create a scheduled task plugin for this
Doing it automatically would be preferred for sure.
If not automatically, then the notice message after update with a link or button to trigger reindexing would be second best. Update a field, see the notice, click the button to reindex OR ignore because you're still making changes, and then click the button to reindex when you're done
It is not possible to automatically reindex all of this, because we are changing a field and this field might be referenced in thousands of articles (or other content items). Depending on the server and everything, it might take days to re-index all of that and that is simply not something that can be done when clicking on save in the field edit form. We also don't have a link (at the moment) to redirect to the indexing process, because that process normally opens a modal and then fires of a few ajax requests. It might be worth to revisit that in the future and to redesign that process to go to a specific page instead of inside a modal.
The search component always searched directly on the live data, which is why you couldn't get sorting by relevance, filters and depending on your setup could run into performance issues.
Can smart Search get a switch between "live" and "index" ?
On bigger sites it seems to make sense - I see on a website with 90.000 articles the indexing never gets finished and ends up in a server error. (It's a Joomla 3.10.11 site tough)
No, you can't switch between "live" and "index".
Just an idea: write a scheduler task plugin for reindexing and mention it in the blue description box of smart search or enable it by default (including a check if smart search is active)
It does what it should - for me it works and is very helpful
I like @bembelimen's suggestion. In the meantime the limitations should be documented in the help screen docs.
Will test later today. :) Thank you
the limitation referred to here is nothing new - you just noticed it. Changing an access level for example didnt force a re-index.
Please merge as is
Would be good to have some tests here before merging
PS C:\htdocs\j42> php .\cli\joomla.php finder:index -vvv
Finder Indexer
==========================
Starting Indexer
Setting up Smart Search plugins
Setup 4651 items in 0.134 seconds.
In PluginHelper.php line 50:
[Error]
Call to undefined method Joomla\CMS\Application\ConsoleApplication::getTemplate()
Exception trace:
at C:\htdocs\j42\libraries\src\Plugin\PluginHelper.php:50
Joomla\CMS\Plugin\PluginHelper::getLayoutPath() at C:\htdocs\j42\administrator\components\com_fields\src\Plugin\FieldsPlugin.php:142
Joomla\Component\Fields\Administrator\Plugin\FieldsPlugin->onCustomFieldsPrepareField() at C:\htdocs\j42\libraries\src\Plugin\CMSPlugin.php:279
Joomla\CMS\Plugin\CMSPlugin->Joomla\CMS\Plugin\{closure}() at C:\htdocs\j42\libraries\vendor\joomla\event\src\Dispatcher.php:486
Joomla\Event\Dispatcher->dispatch() at C:\htdocs\j42\libraries\src\Application\EventAware.php:107
Joomla\CMS\Application\ConsoleApplication->triggerEvent() at C:\htdocs\j42\plugins\fields\subform\subform.php:209
PlgFieldsSubform->onCustomFieldsPrepareField() at C:\htdocs\j42\libraries\src\Plugin\CMSPlugin.php:279
Joomla\CMS\Plugin\CMSPlugin->Joomla\CMS\Plugin\{closure}() at C:\htdocs\j42\libraries\vendor\joomla\event\src\Dispatcher.php:486
Joomla\Event\Dispatcher->dispatch() at C:\htdocs\j42\libraries\src\Application\EventAware.php:107
Joomla\CMS\Application\ConsoleApplication->triggerEvent() at C:\htdocs\j42\administrator\components\com_fields\src\Helper\FieldsHelper.php:207
Joomla\Component\Fields\Administrator\Helper\FieldsHelper::getFields() at C:\htdocs\j42\administrator\components\com_finder\src\Indexer\Helper.php:413
Joomla\Component\Finder\Administrator\Indexer\Helper::addCustomFields() at C:\htdocs\j42\plugins\finder\content\content.php:330
PlgFinderContent->index() at C:\htdocs\j42\administrator\components\com_finder\src\Indexer\Adapter.php:244
Joomla\Component\Finder\Administrator\Indexer\Adapter->onBuildIndex() at C:\htdocs\j42\libraries\src\Plugin\CMSPlugin.php:279
Joomla\CMS\Plugin\CMSPlugin->Joomla\CMS\Plugin\{closure}() at C:\htdocs\j42\libraries\vendor\joomla\event\src\Dispatcher.php:486
Joomla\Event\Dispatcher->dispatch() at C:\htdocs\j42\libraries\src\Application\EventAware.php:107
Joomla\CMS\Application\ConsoleApplication->triggerEvent() at C:\htdocs\j42\libraries\src\Console\FinderIndexCommand.php:388
Joomla\CMS\Console\FinderIndexCommand->index() at C:\htdocs\j42\libraries\src\Console\FinderIndexCommand.php:209
Joomla\CMS\Console\FinderIndexCommand->doExecute() at C:\htdocs\j42\libraries\vendor\joomla\console\src\Command\AbstractCommand.php:235
Joomla\Console\Command\AbstractCommand->execute() at C:\htdocs\j42\libraries\vendor\joomla\console\src\Application.php:1181
Joomla\Console\Application->runCommand() at C:\htdocs\j42\libraries\vendor\joomla\console\src\Application.php:403
Joomla\Console\Application->doExecute() at C:\htdocs\j42\libraries\src\Application\ConsoleApplication.php:202
Joomla\CMS\Application\ConsoleApplication->doExecute() at C:\htdocs\j42\libraries\vendor\joomla\console\src\Application.php:448
Joomla\Console\Application->execute() at C:\htdocs\j42\libraries\src\Application\ConsoleApplication.php:255
Joomla\CMS\Application\ConsoleApplication->execute() at C:\htdocs\j42\cli\joomla.php:76
@brianteeman did you applied changes from #38585 before this patch?
okay, I see, there another one getLayoutPath
for plugins, it cannot work in non Web context:
joomla-cms/libraries/src/Plugin/PluginHelper.php
Lines 48 to 50 in f520c98
hmhm
Thanks for this feature. Joomla is cooler and cooler versions after versions bringing useful and powerful features for developers and content oriented websites thanks for all your hard work Super Joomlers!
@Hackwar after apply the patch, only worked after I edit an article. But did not worked when I first click the mass indexer in the smart search component.
Also, I got this. I think this is expected right? And the user need add a override to this string in the administrator?
Title |
|
Title |
|
Labels |
Added:
PR-5.0-dev
PR-4.4-dev
Removed: PR-4.3-dev |
Labels |
Added:
?
Removed: PR-4.4-dev |
Status | Pending | ⇒ | Closed |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2023-04-18 12:06:28 |
Closed_By | ⇒ | Hackwar |
Why closed? Should we reopen the original issue?
Status | Closed | ⇒ | New |
Closed_Date | 2023-04-18 12:06:28 | ⇒ | |
Closed_By | Hackwar | ⇒ |
Status | New | ⇒ | Pending |
Status | Pending | ⇒ | Fixed in Code Base |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2023-05-29 08:19:44 |
Closed_By | ⇒ | HLeithner | |
Labels |
Added:
Feature
Removed: ? |
thanks, we need documentation for this.
Thanks @Hackwar for re-doing this, it's a nice and important function missing in the indexer!