fix(did-you-mean): include post_title in phrase suggester#4331
Open
faisalahammad wants to merge 1 commit into
Open
fix(did-you-mean): include post_title in phrase suggester#4331faisalahammad wants to merge 1 commit into
faisalahammad wants to merge 1 commit into
Conversation
- Adds an ep_did_you_mean field combining post_title and post_content via copy_to. - Switches the phrase suggester from post_content.shingle to ep_did_you_mean so titles provide suggestion candidates. - Updates mapping tests and adds title-based suggestion tests. Fixes 10up#3554
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Did You Mean only used
post_content.shingle, so suggestions missed keywords that live inpost_title— like WooCommerce product names. This fix adds anep_did_you_meanfield that combinespost_titleandpost_contentviacopy_to, and switches the phrase suggester to use that field.Fixes #3554
Changes
includes/classes/Feature/DidYouMean/DidYouMean.phpBefore:
After:
Why: The suggester now has access to the same keywords the search query uses, so misspelled title terms like
shircan suggestshirt.tests/php/features/TestDidYouMean.phpBefore: mapping tests only checked
post_content.shingle, and there was no test for title-only suggestions.After: mapping tests now assert the
ep_did_you_meanfield andcopy_tomappings exist, and two new tests verify suggestions frompost_title.Why: Prevents regression and verifies the reported scenario.
Testing
Test 1: Title-only suggestion
Sleek Cotton Shirtand empty content.shir.Result: suggested term is
shirt.Test 2: Existing content suggestions still work
Test post.teet.Result: suggested term is
test.Automated:
All 19 tests pass.