Recent

Fuzzy_SearchclassPro only

Class to handle fuzzy search — MySQL stored-function lifecycle and score SQL generation.

Namespace: WebberZone\Better_Search\Pro
Source: includes/pro/class-fuzzy-search.php line 22

Methods

__construct()

Constructor.

Line: 27

public function __construct(  );

activation_hook()

Activation hook.

Since: 4.0.0
Line: 48

public function activation_hook(  );

create_fuzzy_index() static

Recreate the fuzzy helper functions in the database.

Since: 4.0.0
Line: 57

static public function create_fuzzy_index(  );

delete_fuzzy_index() static

Drop all fuzzy stored functions.

Since: 4.3.0
Line: 276

static public function delete_fuzzy_index(  );

is_fuzzy_index_installed() static

Check if the fuzzy index is installed.

Since: 4.0.0
Line: 293

static public function is_fuzzy_index_installed(  ): bool;

Returns: bool — True if both functions are installed, false otherwise.

is_levenshtein_function_installed() static

Check if the Levenshtein function is installed.

Since: 4.0.0
Line: 332

static public function is_levenshtein_function_installed(  ): bool;

Returns: bool — True if the function is installed, false otherwise.

is_phrase_similarity_lev_installed() static

Check if the levenshtein phrase similarity function is installed.

Since: 4.0.0
Line: 343

static public function is_phrase_similarity_lev_installed(  ): bool;

Returns: bool — True if the function is installed, false otherwise.

is_phrase_similarity_soundex_installed() static

Check if the soundex phrase similarity function is installed.

Since: 4.0.0
Line: 354

static public function is_phrase_similarity_soundex_installed(  ): bool;

Returns: bool — True if the function is installed, false otherwise.

get_fuzzy_index_name() static

Get the fuzzy index name.

Since: 4.0.0
Line: 383

static public function get_fuzzy_index_name(  ): string;

Returns: string — The fuzzy index name.

get_fuzzy_index_level() static

Get the fuzzy index level.

Since: 4.0.0
Line: 395

static public function get_fuzzy_index_level( $args = ... ): int;
Type Name Description
array $args Array of arguments.

Returns: int — The fuzzy index level.

has_boolean_operators() static

Whether a search string carries FULLTEXT boolean operators.

Operators like +term or -term express explicit intent that fuzzy or phonetic matching would undermine, so every search path has to switch fuzzy off for them, not just the ordinary one. The operator must be followed by a word character so hyphenated words like “state-of-the-art” do not false-positive.

Since: 4.5.0
Line: 425

static public function has_boolean_operators( string $search_query ): bool;
Type Name Description
string $search_query The raw search string.

Returns: bool — True when the query uses boolean operators.

is_fuzzy_active()

Check whether fuzzy scoring is active for a given search query.

Since: 4.3.0
Line: 438

public function is_fuzzy_active( string $search_query, array $args = ... ): bool;
Type Name Description
string $search_query The raw search string.
array $args Query args.

Returns: bool

get_fuzzy_score_sql()

Build the fuzzy score SQL fragment for a given search query.

When a content column and weight are supplied, the score is the sum of the title fuzzy score and the content fuzzy score, ensuring that a typo present only in post_content still produces a positive score.

Since: 4.3.0
Line: 464

public function get_fuzzy_score_sql( string $search_query, int $weight_title, array $args = ..., string $title_column = ..., string $content_column = ..., int $weight_content = ... ): string;
Type Name Description
string $search_query The raw search string.
int $weight_title Title weight used to derive the fuzzy weight.
array $args Query args.
string $title_column Optional column expression. Defaults to wp_posts.post_title.
string $content_column Optional content column expression. When non-empty, its score is added.
int $weight_content Content weight used to derive the content fuzzy weight.

Returns: string — SQL fragment or empty string.

get_did_you_mean_suggestion()

Find the closest known-good search term from the search log for a “Did you mean” suggestion.

Since: 4.4.0
Line: 518

public function get_did_you_mean_suggestion( string $token ): ?string;
Type Name Description
string $token The single search token that returned zero results.

Returns: ?string — Suggested term, or null if nothing close enough was found.

find_closest_term() static

Shared first-letter + length-window prefilter + wz_levenshtein lookup.

Used by both the search-log corpus (Fuzzy_Search) and the content-index corpus (Spell_Dictionary). SOUNDEX() is not used because it rejects single-edit typos it should catch (e.g. SOUNDEX(‘WordPress’) != SOUNDEX(‘wordpess’)).

Since: 4.4.0
Line: 551

static public function find_closest_term( string $token, string $table, string $word_col, string $freq_col, int $min_freq = ... ): ?string;
Type Name Description
string $token Search token.
string $table Fully-prefixed table name.
string $word_col Word column name.
string $freq_col Frequency column name.
int $min_freq Minimum frequency to qualify. Default 0.

Returns: ?string — Closest term, or null.

find_closest_terms() static

Find the closest known-good terms from a corpus.

Since: 4.5.0
Line: 570

static public function find_closest_terms( string $token, string $table, string $word_col, string $freq_col, int $min_freq = ..., int $limit = ... ): array;
Type Name Description
string $token Search token.
string $table Fully-prefixed table name.
string $word_col Word column name.
string $freq_col Frequency column name.
int $min_freq Minimum frequency to qualify. Default 0.
int $limit Maximum terms to return. Default 3.

Returns: array — Closest terms.

missing_index_notice()

Display admin notice if the fuzzy index is not created.

Since: 4.0.0
Line: 663

public function missing_index_notice(  );