Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: Did you mean #3425

Merged
merged 15 commits into from
Jun 7, 2023
Merged

Feature: Did you mean #3425

merged 15 commits into from
Jun 7, 2023

Conversation

burhandodhy
Copy link
Contributor

@burhandodhy burhandodhy commented Apr 3, 2023

Description of the Change

This PR adds the 'Did you mean' functionality just like other search engines have. The algorithm on ES will detect any typos in the search term and based on the result, the most preferred term will be disabled. To add the functionality to the search page, the user has to call the function \ElasticPress\Features::factory()->get_registered_feature( 'did-you-mean' )->get_suggestion();

Closes #2089

How to test the Change

  • Enable the "Did You Mean" Feature
  • Add the method \ElasticPress\Features::factory()->get_registered_feature( 'did-you-mean' )->get_suggestion(); on theme search template.
  • Search a term with typo

This feature includes a setting that applies when the search results yield no matches.

  1. "Display all the suggestions": When this option is enabled, ElasticPress will display all suggested terms.
  2. "Automatically redirects user to top suggestion": Enabling this option will automatically redirect the user to the top suggested term when there are no search results.

Changelog Entry

Added - 'Did you mean' functionality when there is typo in search term

Credits

Props @burhandodhy

Checklist:

  • I agree to follow this project's Code of Conduct.
  • I have updated the documentation accordingly.
  • I have added tests to cover my change.
  • All new and existing tests pass.

@burhandodhy burhandodhy changed the title Integrate search suggestion Feature: Did you mean May 25, 2023
Copy link
Member

@felipeelia felipeelia left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@burhandodhy identified some changes we'll need to do but happy to talk about it next week.

elasticpress.php Outdated Show resolved Hide resolved
includes/classes/Feature/DidYouMean/DidYouMean.php Outdated Show resolved Hide resolved
includes/classes/Feature/DidYouMean/DidYouMean.php Outdated Show resolved Hide resolved
includes/classes/Feature/DidYouMean/DidYouMean.php Outdated Show resolved Hide resolved
includes/classes/Feature/DidYouMean/DidYouMean.php Outdated Show resolved Hide resolved
includes/classes/Feature/DidYouMean/DidYouMean.php Outdated Show resolved Hide resolved
includes/classes/Feature/DidYouMean/DidYouMean.php Outdated Show resolved Hide resolved
includes/classes/Indexable/Post/QueryIntegration.php Outdated Show resolved Hide resolved
Add option in feature

WIP

Improvements

Minor changes

Minor changes

Add tests

Minor changes
@burhandodhy burhandodhy marked this pull request as ready for review June 1, 2023 14:49
Copy link
Member

@felipeelia felipeelia left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@burhandodhy Can we also please add some documentation about how people can use this feature?

Copy link
Member

@felipeelia felipeelia left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@burhandodhy some final changes we'll need to make before this can be merged. We also need to add somewhere that code is required to display the suggestions. Thoughts?

Also, I just noticed that the feature is auto-activating on existing installations and that is not something we can do on a minor release. Steps to reproduce:

  • 10updocker wp option patch delete ep_feature_settings did-you-mean
  • git checkout develop
  • git checkout feature/2089

includes/classes/Feature/DidYouMean/DidYouMean.php Outdated Show resolved Hide resolved
includes/classes/Feature/DidYouMean/DidYouMean.php Outdated Show resolved Hide resolved
includes/classes/Feature/DidYouMean/DidYouMean.php Outdated Show resolved Hide resolved
includes/classes/Feature/DidYouMean/DidYouMean.php Outdated Show resolved Hide resolved
includes/classes/Feature/DidYouMean/DidYouMean.php Outdated Show resolved Hide resolved
@felipeelia felipeelia merged commit 8c627a8 into develop Jun 7, 2023
@felipeelia felipeelia deleted the feature/2089 branch June 7, 2023 19:43
@felipeelia felipeelia added this to the 4.6.0 milestone Jun 7, 2023
felipeelia added a commit that referenced this pull request Jun 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feature: Did you mean....?
2 participants