Make WordPress Core

Opened 9 years ago

Last modified 6 months ago

#36420 new enhancement

A more forgiving redirect guesser

Reported by: gorillum's profile gorillum Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version:
Component: Canonical Keywords: dev-feedback 2nd-opinion
Focuses: Cc:

Description

I would like the redirect guesser to be more forgiving using SOUNDS LIKE . Here's a small suggestion:

function redirect_guess_404_permalink() {
        global $wpdb;

        if ( get_query_var('name') ) {
                $where = $wpdb->prepare("(post_name SOUNDS LIKE %s", $wpdb->esc_like( get_query_var('name') ) );
                $where .= $wpdb->prepare(" OR post_name LIKE %s)", $wpdb->esc_like( get_query_var('name') ) . '%');

....

It would be even better if it could be implemented using levenstein distance if that is not too heavy on resources.

https://github.com/fza/mysql-doctrine-levenshtein-function

Change History (5)

#1 @Presskopp
9 years ago

While this sounds like a good idea, I have some notes:

MySQL SOUNDS LIKE is used as SOUNDEX(expr) = SOUNDEX(expr) to retrieve strings sounds similar.
Soundex is a phonetic algorithm for indexing names after English pronunciation of sound.

http://www.w3resource.com/mysql/string-functions/mysql-sounds_like-function.php

Not everyone uses an english environment, so this would be exclusive for the english..

The LIKE operator is commonly used to select data based on patterns. Using the LIKE operator in the right way is essential to increase the query performance.
http://www.mysqltutorial.org/mysql-like

Hmm. Do we want to be performant here?

And if i understand it right, the Damerau–Levenshtein distance would fit even better?
https://samjlevy.com/mysql-levenshtein-and-damerau-levenshtein-udfs/
https://github.com/Oefenweb/damerau-levenshtein/releases

That's all I can say, please tell me if I'm wrong somewhere

Last edited 9 years ago by Presskopp (previous) (diff)

#2 @Presskopp
9 years ago

  • Keywords dev-feedback 2nd-opinion added

This ticket was mentioned in Slack in #core by presskopp. View the logs.


7 years ago

#4 @Presskopp
6 months ago

#61487 was marked as a duplicate.

#5 @rcwatson
6 months ago

https://pillser.com/engineering/2024-06-10-website-without-404s outlines a possible solution for creating a fuzzy URL matching system to reduce 404s. If this is something that could be made feasible for WordPress without negatively impacting SEO, it would be a huge win for website owners and SEOs alike.

Note: See TracTickets for help on using tickets.