Expand description
Full-text recipe search.
search walks the .cook and .menu files under a root, scores each
against a query, and returns the matches best first.
§What counts as a match
Every term must match. A recipe is a hit when each whitespace-separated term of the query appears somewhere in its text or in its file name, matched case-insensitively as a substring. Adding a term narrows the results.
Ranking is cooklang-find’s, and is a separate question from matching:
- The file name is matched against the whole query, spaces included. An exact stem match ranks highest, a substring match next.
- The contents are matched against each term, and every occurrence adds a little.
§Why matching is not simply cooklang-find’s scoring
cooklang-find keeps anything scoring above zero, and it scores a file for
any term it contains — so a multi-term query was a union there, and
cook search chicken rice returned recipes with no rice in them. That
contradicted CookCLI’s own help text, which had always promised AND
(https://github.com/cooklang/cookcli/issues/425), and it made a query of
common words match most of a collection.
The union is still what the library returns; search intersects it here.
A single-term query is unaffected, since AND over one term is that term.
Structs§
- Search
Hit - One matching recipe.
- Search
Request - A search to run.
Functions§
- search
- Search the recipes under
req’s root, best match first.