Feature Language Change Documentation Required PR-5.0-dev Pending

User tests: Successful: Unsuccessful:

avatar Hackwar
Hackwar
31 Aug 2022

Pull Request for Issue #12829. Re-do of #36747.

Summary of Changes

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.

Testing Instructions

  1. Make sure that #38585 and #39550 are merged.
  2. Your installation should have some custom fields for com_content or com_contact in it.
  3. Edit a custom field and set the "Smart Search" option to "Make searchable and add as taxonomy".
  4. Run the indexing process either by running the mass indexer in the smart search component or by editing an item and saving it again.
  5. See that the custom field shows up as a taxonomy and can be find by searching for its value.

Documentation Changes Required

The documentation needs to be amended to contain how to implement this feature for third party finder plugins.

avatar Hackwar Hackwar - open - 31 Aug 2022
avatar Hackwar Hackwar - change - 31 Aug 2022
Status New Pending
avatar joomla-cms-bot joomla-cms-bot - change - 31 Aug 2022
Category Administration com_fields com_finder Language & Strings Front End Plugins
avatar Hackwar Hackwar - change - 31 Aug 2022
Labels Added: Language Change PR-4.3-dev
avatar bembelimen
bembelimen - comment - 31 Aug 2022

Thanks @Hackwar for re-doing this, it's a nice and important function missing in the indexer!

avatar coolcat-creations
coolcat-creations - comment - 27 Sep 2022

Thank you @Hackwar is this already ready to test?

avatar Hackwar Hackwar - change - 23 Oct 2022
Labels Added: Documentation Required
avatar crystalenka
crystalenka - comment - 4 Nov 2022

Happy to test this also when it's ready!

avatar Hackwar
Hackwar - comment - 5 Nov 2022

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.

avatar Hackwar
Hackwar - comment - 7 Nov 2022

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.

avatar coolcat-creations
coolcat-creations - comment - 8 Nov 2022

Can index be triggered automatically after doing so? How did the search component handle this?

avatar alikon
alikon - comment - 8 Nov 2022

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

avatar crystalenka
crystalenka - comment - 8 Nov 2022

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

avatar Hackwar
Hackwar - comment - 8 Nov 2022

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.

avatar coolcat-creations
coolcat-creations - comment - 8 Nov 2022

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)

avatar Hackwar
Hackwar - comment - 8 Nov 2022

No, you can't switch between "live" and "index".

avatar bembelimen
bembelimen - comment - 15 Dec 2022

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)

avatar angieradtke
angieradtke - comment - 15 Dec 2022

It does what it should - for me it works and is very helpful

avatar crystalenka
crystalenka - comment - 17 Dec 2022

I like @bembelimen's suggestion. In the meantime the limitations should be documented in the help screen docs.

Will test later today. :) Thank you

avatar brianteeman
brianteeman - comment - 30 Dec 2022

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

avatar laoneo
laoneo - comment - 30 Dec 2022

Would be good to have some tests here before merging

avatar brianteeman
brianteeman - comment - 2 Jan 2023
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
avatar brianteeman
brianteeman - comment - 2 Jan 2023

image

avatar Fedik
Fedik - comment - 2 Jan 2023

@brianteeman did you applied changes from #38585 before this patch?

avatar brianteeman
brianteeman - comment - 2 Jan 2023

@Fedik yes I did

avatar Fedik
Fedik - comment - 2 Jan 2023

okay, I see, there another one getLayoutPath for plugins, it cannot work in non Web context:

public static function getLayoutPath($type, $name, $layout = 'default')
{
$templateObj = Factory::getApplication()->getTemplate(true);

hmhm

avatar Fedik
Fedik - comment - 3 Jan 2023

Okay, so to test this PR have to apply changes from #38585 and from #39550
And then do test here.

avatar richard67
richard67 - comment - 6 Jan 2023

@Hackwar I was so free to fix the conflict in file administrator/language/en-GB/com_fields.ini. It came from the recently merged PR #39534 .

avatar richard67 richard67 - change - 22 Jan 2023
The description was changed
avatar richard67 richard67 - edited - 22 Jan 2023
avatar richard67 richard67 - change - 22 Jan 2023
The description was changed
avatar richard67 richard67 - edited - 22 Jan 2023
avatar richard67
richard67 - comment - 22 Jan 2023

@Hackwar I was so free to fix again a conflict in file administrator/language/en-GB/com_fields.ini. This time it came from the recently merged PR #39051 . I also adapted the description and testing instructions so it's clear that both PR's #38585 and #39550 are needed, too.

avatar alexandreelise
alexandreelise - comment - 4 Mar 2023

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!

avatar carlitorweb
carlitorweb - comment - 6 Mar 2023

@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?

Captura
Captura

avatar Hackwar Hackwar - change - 23 Mar 2023
Title
[4.3] Smart Search: Index custom fields
[4.4] Smart Search: Index custom fields
avatar Hackwar Hackwar - edited - 23 Mar 2023
avatar laoneo
laoneo - comment - 28 Mar 2023

Thank you for your contribution, unfortunately the 4.4-dev branch doesn't get new features. When #40181 is merged this pr should be rebased to 5.0-dev. Thanks for understanding.

avatar Hackwar Hackwar - change - 28 Mar 2023
Title
[4.4] Smart Search: Index custom fields
[5.0] Smart Search: Index custom fields
avatar Hackwar Hackwar - edited - 28 Mar 2023
avatar Hackwar Hackwar - change - 28 Mar 2023
Labels Added: PR-5.0-dev PR-4.4-dev
Removed: PR-4.3-dev
avatar HLeithner HLeithner - change - 7 Apr 2023
Labels Added: ?
Removed: PR-4.4-dev
avatar Hackwar Hackwar - change - 18 Apr 2023
Status Pending Closed
Closed_Date 0000-00-00 00:00:00 2023-04-18 12:06:28
Closed_By Hackwar
avatar Hackwar Hackwar - close - 18 Apr 2023
avatar richard67
richard67 - comment - 18 Apr 2023

Why closed? Should we reopen the original issue?

avatar Hackwar Hackwar - change - 18 Apr 2023
Status Closed New
Closed_Date 2023-04-18 12:06:28
Closed_By Hackwar
avatar Hackwar Hackwar - change - 18 Apr 2023
Status New Pending
avatar Hackwar Hackwar - reopen - 18 Apr 2023
avatar HLeithner HLeithner - change - 29 May 2023
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: ?
avatar HLeithner HLeithner - close - 29 May 2023
avatar HLeithner HLeithner - merge - 29 May 2023
avatar HLeithner
HLeithner - comment - 29 May 2023

thanks, we need documentation for this.

Add a Comment

Login with GitHub to post a comment