PostSearch final class
Minn\Query\PostSearch · public/minn/src/Minn/Query/PostSearch.php · 118 lines
WP_Query's search as the reference writes it (probe wp-query-sql): the search string split into terms (quoted phrases kept whole, single letters and stopwords dropped, ten or more terms or none left searched as one sentence), each term a group of LIKEs over the searched columns (NOT LIKE and AND for an excluded term), the password clause for a visitor, and the relevance order: a CASE ladder for several terms, the title match first for one.
Constants and properties
| const | COLUMNS = array ( 0 => 'post_title', 1 => 'post_excerpt', 2 => 'post_content', ) | |
| const | STOPWORDS = 'about,an,are,as,at,be,by,com,for,from,how,in,is,it,of,on,or,that,the,this,to,was,what,when,where,who,will,with,www' | |
| private | TERM = '/".*?("|$)|((?<=[\\t ",+])|^)[^\\t ",+]+/' |
Public
| static | terms(string $search, callable $stopwords): array# | The terms a search string becomes and how many it was split into.
@return array{terms: list<string>, count: int} | ||||||
| static | checked(array $terms, array $stopwords): array# | The terms worth searching: quotes trimmed (a quoted term keeps its inner spaces), and a single letter or dash, or a stopword, dropped.
@return list<string> | ||||||
| static | stopwords(string $list): array# | The stopword list from its comma-separated (translated) form. @return list<string> | ||||||
| static | columns(array $given): array# | The searched columns: those given that the reference searches, or all three. @return list<string> | ||||||
| static | where(string $table, array $terms, array $columns, string $exclusionPrefix, string $wild): array# | The search's WHERE fragment (no password clause; a visitor's search adds one) and the title matches its order ranks by. An exact search passes no wildcard, and asks for no title matches.
@return array{where: string, titles: list<string>} | ||||||
| static | order(string $table, string $search, int $count, array $titles): string# | The relevance order: for several terms, the whole string in the title, then every term, then any term (up to six), then the whole string in the excerpt and the content (no sentence match when a term is negated); for one term, its title match.
|
Nothing matches.