v0.6.0

Keyword Search

Last updated


How a query string is turned into keywords, matched against stored chunks, ranked, and grouped in the response.

Query Processing


search.Search (internal/search/search.go) validates the request, then prepares keywords:
StepRule
DatabaseMust be a loaded database name, otherwise invalid argument: "<name>" not exist
Queryq must be non-empty, otherwise invalid argument: q is required
Limit1 to 100; missing, zero, negative, non-numeric, or above 100 falls back to 10
TargetEmpty or keyword; anything else returns invalid argument: unknown target "<value>"
Keywordsq is lower-cased, split on whitespace, and de-duplicated

Matching and Ranking


Each keyword becomes a case-insensitive substring match (LOWER(content) LIKE '%keyword%') over live rows only (dismiss = FALSE). A chunk matches when it contains any keyword.
OrderKey
1Number of distinct keywords the chunk contains, highest first
2Row id, oldest first

Substring matching means go also matches golang and google. The % and _ characters in a keyword act as SQL LIKE wildcards. Lower-casing follows SQLite LOWER(), which folds ASCII letters only; text in other scripts matches as written.

Response Shape


Matching chunks are grouped by source file, in the order the first chunk of each file appears in the ranking:
  1. {
  2. "keyword": [
  3. {
  4. "source": "/Users/you/.config/kuradb/notes/inbox/a.md",
  5. "matches": [
  6. { "chunk": 1, "content": "Alpha Go notes\nline two" },
  7. { "chunk": 2, "content": "Second paragraph about SQLite" }
  8. ]
  9. }
  10. ]
  11. }

FieldMeaning
sourceAbsolute path of the file inside the database inbox
matches[].chunk1-based chunk number within that file
matches[].contentFull chunk text

Internal ranking values such as row ids and hit counts are not returned. When nothing matches, the HTTP API returns {"keyword": []} and the MCP tool returns an empty object.

中文