API / Minn\Rest / SearchController

SearchController final readonly class

Minn\Rest\SearchController · public/minn/src/Minn/Rest/SearchController.php · 122 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
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 5

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(string $subtype): array#

The searchable post types: every registered type except the ones the reference keeps out.

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#