ollama_corpus_rerank
Rerank hits. Post-retrieval re-sort of hits from a prior ollama_corpus_search. No Ollama call (no embed, no generate). Three modes: ‘recency’ (newer file mtime wins; stats the file), ‘path_specificity’ (deeper paths win), ‘lexical_boost’ (boosts hits whose preview/heading_path/title contains any lexical_terms — case-insensitive, word-boundary; lexical_terms REQUIRED for this mode). Preserves each hit’s original score + original_rank; appends rerank_score + rank. Use after corpus_search when you need a different ordering heuristic than semantic similarity.
Parameters
Section titled “Parameters”| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
hits |
object[] | yes | — | Hits from a prior ollama_corpus_search (or equivalent). Required fields: id, path, score, chunk_index. Optional: preview, heading_path, title. |
rerank_by |
"recency" \ |
"path_specificity" \ |
"lexical_boost" |
yes |
lexical_terms |
string[] | no | — | Required when rerank_by=‘lexical_boost’. Each term is matched case-insensitively with word-boundaries against preview + heading_path + title. |
Full input schema
Section titled “Full input schema”The JSON Schema below is generated from the same zod schema the server validates against at the wire — it cannot drift from runtime behavior.
{ "$schema": "https://json-schema.org/draft/2020-12/schema", "type": "object", "properties": { "hits": { "minItems": 1, "type": "array", "items": { "type": "object", "properties": { "id": { "type": "string", "minLength": 1 }, "path": { "type": "string", "minLength": 1 }, "score": { "type": "number" }, "chunk_index": { "type": "integer", "minimum": -9007199254740991, "maximum": 9007199254740991 }, "preview": { "type": "string" }, "heading_path": { "type": "array", "items": { "type": "string" } }, "title": { "anyOf": [ { "type": "string" }, { "type": "null" } ] } }, "required": [ "id", "path", "score", "chunk_index" ] }, "description": "Hits from a prior ollama_corpus_search (or equivalent). Required fields: id, path, score, chunk_index. Optional: preview, heading_path, title." }, "rerank_by": { "type": "string", "enum": [ "recency", "path_specificity", "lexical_boost" ], "description": "'recency' stats file mtime (newer wins). 'path_specificity' prefers deeper paths. 'lexical_boost' requires lexical_terms." }, "lexical_terms": { "description": "Required when rerank_by='lexical_boost'. Each term is matched case-insensitively with word-boundaries against preview + heading_path + title.", "type": "array", "items": { "type": "string", "minLength": 1 } } }, "required": [ "hits", "rerank_by" ]}Envelope
Section titled “Envelope”Every tool returns the standard envelope — tier_used, model, tokens_in/tokens_out, elapsed_ms, backend provenance, warnings. See Envelope & tiers.
Source
Section titled “Source”Schema + handler: src/tools/corpusRerank.ts · registration: src/index.ts
Back to the Tool Reference.