API / Minn\Rest / SearchController

SearchController final readonly class

Minn\Rest\SearchController · public/minn/src/Minn/Rest/SearchController.php · 171 lines

wp/v2 search over published content: id, title, url, type, and the post type as subtype. Ordered the way the reference orders a search: a title holding every term first, then a title holding any term, then an excerpt match, then a content match, newest first within a rank.

Used by 1

Constants and properties

privateMAX_PER_PAGE = 100
privateIDS = array ( 'exclude' => array ( 'description' => 'Ensure result set excludes specific IDs.', 'type' => 'array', 'items' => array ( 'type' => 'integer', ), 'default' => array ( ), 'required' => false, ), 'include' => array ( 'description' => 'Limit result set to specific IDs.', 'type' => 'array', 'items' => array ( 'type' => 'integer', ), 'default' => array ( ), 'required' => false, ), )

Read by list(): the ids the results keep to, and those they leave out.

privateLAST_OFFSET = 1.8446744073709552E+19

The largest row offset the database takes; a page past it fails the query, and the reference then refuses the page.

privatereadonly Minn\Db $db

Promoted from the constructor.

privatereadonly Minn\Rest\Types $types

Promoted from the constructor.

privatereadonly Minn\Front\Permalinks $permalinks

Promoted from the constructor.

privatereadonly Minn\Rest\RestUrl $url

Promoted from the constructor.

privatereadonly Minn\Rest\Caller $caller

Promoted from the constructor.

Public

new__construct(Minn\Db $db, Minn\Rest\Types $types, Minn\Front\Permalinks $permalinks, Minn\Rest\RestUrl $url, Minn\Rest\Caller $caller)#
methodlist(Minn\Http\Request $request): Minn\Http\ResponseGET /wp/v2/search (public)#

Search across post types with the reference's relevance order.

Internals 6

Private and protected methods: how the class does its work. Not a contract; they change whenever the code is tidied.

privateitem(Minn\Content\PostRecord $row): array#
privatesubtypes(mixed $subtype): array#

The post types searched: every searchable one for "any", otherwise those asked for that are post types (a taxonomy's name is another handler's subtype and finds no post here), and posts when none is left, as the reference's query falls back. A subtype is refused only when no search handler offers it, with the schema's own words: the post types', the taxonomies' and "any".

@return list<string>
privatetaxonomies(): array#

The taxonomies the term search offers as subtypes: those shown in REST that are public. @return list<string>

@return list<string>
privaterankExpression(array $terms, array $params): string#

A CASE that ranks a title match over an excerpt over a content match.

privateterms(string $search): array#
@return list<string>
privateescapeLike(string $value): string#