Markdown knowledge base search: okf find
Markdown knowledge base search with okf find
Section titled “Markdown knowledge base search with okf find”Run okf find and get ranked concepts from the shell, narrowed by one --where filter. Add the semantic arm when you want embeddings.
The output below comes from okf 0.2.5, run against a throwaway copy of the test catalogue.
How it looks
Section titled “How it looks”Without an index, find falls back to a substring scan and says so on stderr. Build the FTS5 index once, then ask again:
$ okf build-indexindexed 25 concept(s) -> <catalogue>/.fts/fts.sqlite[exit 0]$ okf find recipe --limit 2note: semantic arm skipped (.tagvec cache/concept embeddings absent) — lexical results only------rank: 1title: Recipes overviewtype: Conceptpath: recipes/overviewdescription: Overview of the recipesbody-snippet: # Overview See [pasta](pasta.md), [bread](/okf-cli/recipes/bread.md), [soup](soup.md) and [[salad]].…provenance: lexical------rank: 2title: cookingtype: Contextpath: _ctx/cookingdescription: Cooking basicsbody-snippet: …| |---|---|---|---| | 1 | pflicht | [bread](/okf-cli/recipes/bread.md) | | | 2 | pflicht | [pasta](/okf-cli/recipes/pasta.md) | | | 3 | pflicht | [soup](…provenance: lexical------[exit 0]Every hit carries rank, its 1-based position in the list, and provenance, the arm that produced it. Add --breakdown to see the raw score per hit:
score: 100/100contrib: bm25 (fts5 index; field-level breakdown not available)score: 88/100contrib: bm25 (fts5 index; field-level breakdown not available)Why it matters
Section titled “Why it matters”You get ranked hits without leaving the shell, and the same --where filter selects the same concepts for okf list.
What you get
Section titled “What you get”- Ranked results from a SQLite FTS5 index with BM25 weights: title 3.0, tags 2.0, body 1.0.
- An optional semantic arm that ranks by embedding similarity.
- One
--whereexpression that narrows by type, tag, path, archived state and any frontmatter key. See the--wherereference. okf listreturns the complete, unranked set that a--whereselects.
------rank: 1title: Souptype: Recipepath: recipes/soupdescription: Tomatensuppebody-snippet: …weis Use a pot <size>. Compare with [bread](/okf-cli/recipes/bread.md).…provenance: lexical------[exit 0]------title: Gazpachotype: Recipepath: recipes/seasonal/gazpachodescription: Cold tomato soup------title: Souptype: Recipepath: recipes/soupdescription: Tomatensuppe------list: 2 concept(s)[exit 0]The filter applies before the cut to --limit. Archived concepts stay hidden unless the expression names archived.
How the two arms work
Section titled “How the two arms work”flowchart LR Q[query + --where] --> L[Lexical arm: FTS5 / BM25] Q --> S[Semantic arm: embeddings] L --> R[Ranked list] S --> R R --> O[rank 1..limit]
The list order is the rank. The two arms never blend scores: the arm that owns the ranking hands over its order. Raw scores stay out of the default output. --breakdown prints them, one score: line per hit.
Details
Section titled “Details”okf build-indexbuilds or refreshes.fts/fts.sqlite.--if-staleskips the rebuild when the index is current. The file shows as untracked in git.- Without the index,
findscans substrings and printsnote: lexical index absent — falling back to substring scan; runokf build-indexfor BM25 ranking. Hits then printprovenance: lexical, notsubstringas the help says [gnnc]. - The semantic arm reads
.tagvec/tag_vectors.sqlite.okf build-semantic-indexfills it withvoyage-3-largeembeddings and needsVOYAGE_API_KEY. The tag commands use a local Ollamabge-m3atlocalhost:11434(see Tags and registry). The endpoint and model are fixed today; a configurable endpoint is planned [76eb]. - When the semantic data is absent,
findprintsnote: semantic arm skipped (.tagvec cache/concept embeddings absent) — lexical results onlyand the lexical result stands alone. Degradation never changes the exit code. okf recentlists the newest concepts and takes the same--where.--include-topicswidens the search from the.okf.tomlbundle to topic folders.--jsonprints one envelope.dataholdshitsandnearest_tags; degradation notes arrive inwarnings.
Limits
Section titled “Limits”build-semantic-indexwithoutVOYAGE_API_KEYexits 0 and writes nothing. It printsnote: semantic index build skipped (VOYAGE_API_KEY not set). Check the exit code and the note, not only success.--expand-tagsis off by default. The project measured it as ineffective for the vocabulary mismatch it targets.- The semantic arm was not run for this page. Its behaviour with a key is read from the code, not from a run.