Skip to content

Conversation

@Hackwar
Copy link
Member

@Hackwar Hackwar commented Jan 20, 2022

Pull Request for Issue #12829.

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.

Testing Instructions

  1. Your installation should have some custom fields for com_content or com_contact in it.
  2. Edit a custom field and set the "Smart Search" option to "Make searchable and add as taxonomy".
  3. Run the indexing process either by running the mass indexer in the smart search component or by editing an item and saving it again.
  4. 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.

Notes

  1. Since 4.1 is in RC, this will have to go into 4.2. Since there is no 4.2-dev branch yet, I'm pointing this towards 4.1-dev for now.

@joomla-cms-bot joomla-cms-bot added Language Change This is for Translators PR-4.1-dev labels Jan 20, 2022
@Hackwar
Copy link
Member Author

Hackwar commented Jan 20, 2022

This also solves #13338

@laoneo
Copy link
Member

laoneo commented Jan 20, 2022

Nice, how would the data be represented on the site part in a search result?

@Hackwar
Copy link
Member Author

Hackwar commented Jan 20, 2022

Nice, how would the data be represented on the site part in a search result?

If it is a taxonomy, it would simply use the given string in a dropdown. Otherwise it wouldn't display the custom fields by default. For output, you should create your own layout, maybe load custom fields again or similar stuff.

@Quy Quy added PR-4.2-dev and removed PR-4.1-dev labels Jan 24, 2022
@Hackwar Hackwar changed the base branch from 4.1-dev to 4.2-dev January 24, 2022 20:19
@drmenzelit
Copy link
Contributor

I have tested this item ✅ successfully on 92b39ea

Tested with three different fields:

  • Text field in Content
  • Text field in Contacts
  • List field in Contacts
    Tried the different parameters in the fields.
    It works as described.

Great PR! Thank you Hannes.


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/36747.

@Quy
Copy link
Contributor

Quy commented May 17, 2022

I have not checked all field types so should this setting be excluded such as media, list of images...?

36747

@coolcat-creations
Copy link
Contributor

We installed this PR with the prebuilt package and smart search does not work at all (even not with normal content)

  • Plugins are enabled
  • Fields are setup
  • Menu item is set up
  • Content is successfully indexed

This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/36747.

@Hackwar
Copy link
Member Author

Hackwar commented May 19, 2022

Can you be a bit more specific? Does it return any search results or do you get a white screen in the frontend or backend? Since this only changes how stuff is indexed and doesn't do anything related to the actual searching, this might even be a new bug.

@coolcat-creations
Copy link
Contributor

Article Content is for example cheeseburger and when you search for cheeseburger, the article can't be found at all. It says that there are no search results for that.

@Hackwar
Copy link
Member Author

Hackwar commented May 19, 2022

I think I found the issue and it is not related to this PR. I'm guessing that you wrote an article, saved it and then went to the frontend searching for it, right? We are storing the current time and date as publish_start date. In the SQL query to retrieve the results, we do compare that timestamp with the current time minus the seconds. That last part is done so that such a query doesn't change every second and the database has a chance to cache it. So if you wait a few more seconds until the next minute ticks around, the results should show up. I was able to recreate exactly that behavior. But: All of this is not related to this PR.

@webnet-assmann
Copy link

I have tested this item ✅ successfully on 92b39ea

testet with 3 different custome fields:
Content Field: tet and editor
contact field: text
Thanks a lot Hannes!


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/36747.

@chmst
Copy link
Contributor

chmst commented May 20, 2022

RTC


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/36747.

@joomla-cms-bot joomla-cms-bot added the RTC This Pull Request is Ready To Commit label May 20, 2022
@rdeutz rdeutz merged commit f001c84 into joomla:4.2-dev May 20, 2022
@joomla-cms-bot joomla-cms-bot removed the RTC This Pull Request is Ready To Commit label May 20, 2022
@heelc29
Copy link
Contributor

heelc29 commented May 21, 2022

@rdeutz Can you add this to milestone

@Hackwar Hackwar deleted the 4.2-finder-customfields branch May 21, 2022 06:18
@zero-24 zero-24 modified the milestones: Joomla 4.1.4, Joomla 4.2.0 May 21, 2022
@joomdonation
Copy link
Contributor

@Hackwar Look like we attempted to index custom fields before already in fields system plugin https://github.com/joomla/joomla-cms/blob/4.2-dev/plugins/system/fields/fields.php#L512

However, look like that code is not working at all. With the feature introduce in this PR, what should we do with that existing code ?

@Hackwar
Copy link
Member Author

Hackwar commented May 22, 2022

That code is pretty much useless. We should delete it entirely.

heelc29 added a commit to heelc29/joomla that referenced this pull request Jun 5, 2022
@wilsonge wilsonge mentioned this pull request Jul 4, 2022
roland-d added a commit that referenced this pull request Jul 5, 2022
This reverts commit f001c84

Signed-off-by: Roland Dalmulder <[email protected]>
@roland-d
Copy link
Contributor

roland-d commented Jul 5, 2022

@Hackwar I have reverted this PR in light of the issues found in issue #38222 Please review the findings and propose a new PR which we can use. Thank you.

@roland-d roland-d removed this from the Joomla! 4.2.0 milestone Jul 5, 2022
@richard67 richard67 modified the milestone: Joomla! 4.2.0 Jul 10, 2022
@Hackwar Hackwar restored the 4.2-finder-customfields branch August 30, 2022 18:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Language Change This is for Translators

Projects

None yet

Development

Successfully merging this pull request may close these issues.