{"slug": "local-hybrid-search-for-technical-documentation", "title": "Local Hybrid Search for Technical Documentation", "summary": "A walkthrough published on Manticore Search's blog demonstrates local hybrid lexical-plus-vector search over ten authored documentation snippets using Manticore Search 29.9.0, the Xenova/all-MiniLM-L6-v2 embedding model, and a Docker Compose setup limited to two CPUs and 3 GiB of memory, run on Linux/amd64 on October 29, 2026. The example keeps embedding inference local so document text is never sent to a hosted embedding API, and the author reports that in one test case combining lexical and vector rankings put the wrong page first. The fixtures are teaching examples, not production documentation or actual Manticore error codes, and the results do not measure throughput or relevance on a real corpus.", "body_md": "A documentation search engine needs to handle both exact error codes and descriptions of symptoms. In this example, `E1042` and “workers cannot borrow a session because every slot is busy” should lead to the same page about an exhausted connection pool. The code is easy to match; the symptom uses different words from the page.\n\nYou can run both searches locally, without sending document text to a hosted embedding API. This walkthrough uses Manticore Search, a small local embedding model, and ten short documentation snippets. In one of the test cases, combining the lexical and vector rankings puts the wrong page first.\n\n[Download the complete example](local-documentation-hybrid-search.zip)\n. It includes the fixtures, Docker Compose configuration, Python runner, captured results, and a network-isolation check. Python uses only its standard library; you do not need an ML environment or an API key.\n\n## What We Tested\n\nThese are **authored teaching fixtures**, not production documentation or actual Manticore error codes. The ten snippets cover connection pools, connection refusal, TLS certificates, storage, access tokens, permissions, replication, and query deadlines. Each is one short troubleshooting section, with an ID, title, body, and exact code attribute.\n\nFor example, document 1 is:\n\n**E1042: Connection pool exhausted**\n\nAll database connections are checked out. A request waits until the acquisition deadline expires. Close leaked sessions, shorten transactions, or reduce concurrent workers before increasing the pool size.\n\nDocument 2 describes connection refusal and contains the word “session.” That overlap turns out to matter.\n\nThe example was run on Linux/amd64 on October 29, 2026, with the container limited to two CPUs and 3 GiB of memory. The [official image listing](https://hub.docker.com/r/manticoresearch/manticore)\nidentified `29.9.0` as the stable release. The download pins that tag to this image digest:\n\n```\nsha256:461b419739a2bbbffb4be0b32db26c41d7b435bf7fd1fce95b414ca5ccbb3775\n```\n\nActual `SELECT VERSION()` output:\n\n```\n29.9.0 58e88d5ab@26091108 (columnar 14.2.1 cb282a2@26090615) (secondary 14.2.1 cb282a2@26090615) (knn 14.2.1 cb282a2@26090615) (embeddings 1.1.1 cb282a2@26090615)\n```\n\nThe container also reported Buddy `4.4.3+26083121-976df147`. The test used the stable image. These results describe retrieval on the teaching fixtures; they do not measure throughput or relevance on a real documentation corpus.\n\n## Starting the Example\n\nYou need Docker with Compose v2, Python 3, curl, and unzip. Allow internet access for the initial image and model downloads. Use a fresh demo instance: the loader creates a table named `docs` and intentionally fails if that table already exists.\n\n```\ncurl -fLO https://manticoresearch.com/blog/local-documentation-hybrid-search/local-documentation-hybrid-search.zip\nunzip local-documentation-hybrid-search.zip\ncd local-documentation-hybrid-search\n\ndocker compose up -d\nuntil curl -fsS http://127.0.0.1:19318/sql?mode=raw \\\n  -d 'SELECT 1' >/dev/null; do sleep 1; done\npython3 demo.py --load | tee results.txt\n```\n\nCompose names the project and container `manticore-article01`. It binds HTTP port `19318` and MySQL port `19316` to loopback only. A named volume keeps the database and downloaded model cache across restarts. The [Docker manual](https://manual.manticoresearch.com/Installation/Docker)\ndescribes the image and standard ports.\n\nTo repeat the queries without loading again:\n\n```\npython3 demo.py\n```\n\nThe script prints every SQL statement and its database response, followed by the three result lists as IDs. It checks the fixture count and exact-code lookups. It does not assert that hybrid search must win.\n\n## Keeping Embedding Inference Local\n\nThe runner creates this table:\n\n```\nCREATE TABLE docs (\n  title TEXT,\n  body TEXT,\n  code STRING,\n  vec FLOAT_VECTOR KNN_TYPE='hnsw' HNSW_SIMILARITY='cosine'\n    MODEL_NAME='Xenova/all-MiniLM-L6-v2'\n    FROM='title,body'\n);\n```\n\n`title` and `body` are searchable text. `code` is a separate string attribute for an exact filter. The model embeds the title and body on insertion; the same model embeds text passed to `KNN()`. The [KNN manual](https://manual.manticoresearch.com/Searching/KNN)\ndocuments auto-embeddings and the `MODEL_NAME`/` FROM` options.\n\nThe [Xenova model](https://huggingface.co/Xenova/all-MiniLM-L6-v2)\nprovides ONNX weights. Manticore runs inference inside the container, so the embeddings are self-hosted: there is no hosted embedding or LLM call in this example. For background on the feature and its implementation, see [auto-embeddings](https://manticoresearch.com/blog/auto-embeddings/)\nand the [ONNX backend article](https://manticoresearch.com/blog/onnx-embeddings-speedup/)\n.\n\n“Local” does not mean “nothing is downloaded.” In this run the model cache resolved to Hugging Face revision `751bff37182d3f1213fa05d7196b954e230abad9`. The package records the downloaded file hashes. The SQL model name itself does not pin that revision, so future fresh downloads may differ. A second run on November 9, 2026, with a fresh download and the same image digest, produced the same four cache file hashes and identical query output. Preserve the warmed volume and cache anyway when you need this exact run.\n\n*Architecture diagram of this example, not measured output. Initial model downloads happen before the isolated runtime check.*\n\n## Lexical, Vector, and Hybrid Queries\n\nYou can run SQL through the container’s bundled MySQL client:\n\n```\ndocker exec -it manticore-article01 mysql -h127.0.0.1 -P9306\n```\n\nFirst, the lexical query asks which documents contain the code:\n\n```\nSELECT id, title, weight() AS score\nFROM docs WHERE MATCH('E1042')\nORDER BY score DESC, id ASC LIMIT 3;\n```\n\nCaptured row:\n\n```\nid  title                             score\n1   E1042: Connection pool exhausted   1718\n```\n\nNext, vector search asks which snippets resemble the symptom:\n\n```\nSELECT id, title, knn_dist() AS distance\nFROM docs\nWHERE KNN(vec,10,'workers cannot borrow a session because every slot is busy')\nLIMIT 3;\n```\n\nCaptured rows, with lower cosine distance ranked first:\n\n```\nid  title                             distance\n1   E1042: Connection pool exhausted   0.67388809\n5   E3010: Disk quota exceeded         0.7005797\n6   E3011: Read-only filesystem        0.8074981\n```\n\nFinally, hybrid search combines the code lookup with the symptom search:\n\n```\nSELECT id, title, hybrid_score() AS score\nFROM docs\nWHERE MATCH('E1042')\n  AND KNN(vec,10,'workers cannot borrow a session because every slot is busy')\nLIMIT 3\nOPTION fusion_method='rrf', window_size=10;\n```\n\nCaptured rows:\n\n```\nid  title                             score\n1   E1042: Connection pool exhausted   0.03278688\n5   E3010: Disk quota exceeded         0.01612903\n6   E3011: Read-only filesystem        0.01587302\n```\n\nThe correct page was already first in both individual searches. Hybrid did not improve its rank. It did retain the vector branch’s other suggestions, even though they do not contain `E1042`.\n\nWith `fusion_method='rrf'`, the `MATCH` and `KNN` clauses supply separate ranked lists for fusion. Their `AND` is **not a requirement that each returned document match both signals**. Without that option, the same statement runs as a KNN search filtered by the text match. In a test on this table, `MATCH('borrow | session | busy') AND KNN(vec,3,...)` without `fusion_method` returned only document 2, one row, with no fusion. See the [hybrid search manual](https://manual.manticoresearch.com/Searching/Hybrid_search)\nfor its semantics.\n\n## Where Fusion Helped and Where It Hurt\n\nThe runner uses explicit lexical expressions rather than a hidden query parser. For symptom-only cases, I selected a few content words and joined them with `|` (OR); the vector branch receives the full sentence. For mixed cases, the lexical branch receives the code. These choices are part of the teaching example, not a universal query-processing recipe.\n\nHere are all seven cases from the fresh run. Lists show the first three IDs, or fewer when lexical search has fewer matches. Titles are in `fixtures.json`.\n\n| Case: lexical expression / vector text | Lexical | Vector | Hybrid | \n|---|---|---|---|\n| `E1042` /`E1042` | 1 | 1, 10, 7 | 1, 10, 7 | \n| `borrow \\| session \\| busy` / workers cannot borrow a session because every slot is busy | 2 | 1, 5, 6 | 2, 1, 5 | \n| `E1042` / workers cannot borrow a session because every slot is busy | 1 | 1, 5, 6 | 1, 5, 6 | \n| `secure \\| identity \\| wrong` / the secure endpoint presents an identity for a different domain | none | 4, 3, 8 | 4, 3, 8 | \n| `E1042` / renew an expired TLS certificate | 1 | 4, 3, 7 | 1, 4, 3 | \n| `E9999` /`E9999` | none | 1, 2, 7 | 1, 2, 7 | \n| `sourdough \\| starter` / how to feed a sourdough starter | none | 2, 5, 9 | 2, 5, 9 | \n\nThe pool paraphrase is the clearest regression. Vector search found document 1 first. Lexical search found document 2 because it says “session.” Document 1 says “sessions,” and this table has no stemming or morphology, so `MATCH('session')` returns only document 2 and `MATCH('sessions')` only document 1. Hybrid then promoted document 2 above document 1.\n\n[Reciprocal Rank Fusion (RRF)](https://manticoresearch.com/blog/hybrid-search/)\nadds up one contribution per list a document appears in, based on its position in that list. With the default constant of 60 and the default weight, a rank contributes `1 / (60 + rank)`. Document 2 is first in the lexical list, which gives `1/61 = 0.01639`. It is also sixth in the vector list (distance 0.826), which adds `1/66 = 0.01515`. The total, `0.03154`, beats document 1, which appears only in the vector list at rank 1 and scores `0.01639`. The three displayed vector rows are not the whole list: with `KNN(vec,10,...)` on this ten-document table, the vector search returns all ten documents.\n\nOn this table neither `k` nor `window_size` shortened the vector list. With `KNN(vec,3,...)` instead of `10`, or with `window_size=1` or `window_size=3`, the hybrid query still returned document 2 with `0.03154`, which includes the vector-rank-6 contribution. The manual covers the first case: `k` [does not apply to RAM chunks](https://manual.manticoresearch.com/Searching/KNN)\n, and all ten documents are in the RAM chunk. The second case does not match the manual, which says `window_size` sets how many results each sub-query retrieves: here it changed nothing on 29.9.0 or on the development build 29.11.3. What capped the lists was `max_matches`. With `max_matches=3`, document 2 fell to `0.01639` and lost its vector contribution, even with `window_size=10`. With `max_matches=6`, it returned to `0.03154`. The test covered only this ten-document table in the RAM chunk, and these queries are not in the download, so check the window size on your own tables.\n\nI also tested a lower lexical weight. With the query below, `text` weighted 0.5, document 2 still scored `0.02335` against `0.01639` for document 1, so the order did not change.\n\n```\nSELECT id, hybrid_score()\nFROM docs\nWHERE MATCH('borrow | session | busy') AS text\n  AND KNN(vec,10,'workers cannot borrow a session because every slot is busy') AS dense\nLIMIT 10\nOPTION fusion_method='rrf', window_size=10, fusion_weights=(text=0.5);\n```\n\nThe certificate paraphrase also failed to distinguish the intended hostname mismatch (3) from expiration (4). With no lexical matches, hybrid reproduced the vector ordering. For the conflicting query, fusion put the code’s document first, but that does not resolve the contradiction in the user’s report.\n\nThe last two cases are useful checks for a search UI. An unknown code and an unrelated cooking question still returned documents. The first hybrid score for the cooking question was `0.01639344`, the same rank contribution as any vector-only first-place result. **An RRF score is not a confidence probability.** This example provides no validated threshold for deciding whether an answer exists.\n\n## Exact Codes Need an Explicit Policy\n\nWhen a reader supplies a recognized code, you may want a direct lookup before showing related pages:\n\n```\nSELECT id, title FROM docs WHERE code='E1042';\n```\n\nThat returned only document 1. The corresponding lookup for `E9999` returned no rows. If a code must constrain a hybrid search, add `AND code='E1042'` as an attribute filter; this also returned only document 1 in the conflicting-symptom test.\n\nKeep the distinction visible in your interface: “Exact code match” and “Related troubleshooting” serve different needs. Do not silently treat a semantic neighbor as documentation for an unknown code.\n\nThe `python3 edge-cases.py` checks produced these results:\n\n- `MATCH('E-1042')` found nothing in this schema; punctuation is not a free spelling correction for`E1042` .\n- A malformed `MATCH('(')` returned HTTP 500 with a full-text parser error.\n- `KNN(vec,3,'')` returned documents 10, 8, and 5. An empty query still produced results. Reject blank input in an application.\n\nThe runner’s SQL quoting is for these fixed fixtures. A public search box also needs [full-text query escaping](https://manual.manticoresearch.com/Searching/Full_text_matching/Escaping)\nand a deliberate policy for operators; SQL string escaping alone does not provide that.\n\n## Testing the Network Boundary\n\nAfter loading the model, I attached the container only to an **internal Docker bridge**, removed its external network, and restarted it. Both a Hugging Face request and a direct-IP request failed. All seven search cases still executed, and a newly inserted document received an embedding and ranked first for “newly embedded document.” The test then deleted that extra row.\n\nTo repeat this on the warmed example:\n\n```\nbash offline-check.sh | tee offline-results.txt\n```\n\nThe script temporarily removes host-port access, runs SQL through `docker exec`, and restores the Compose network on exit. It checks that the test network is internal and prints the attached networks. Captured evidence includes:\n\n```\nConnecting to 1.1.1.1:80... failed: Network is unreachable.\n```\n\nThe fresh insert’s captured search row was:\n\n```\nid  title               knn_dist()\n11  Offline insertion   0.37552971\n```\n\nThis demonstrates cached-model inference after a restart without external access in this Docker setup. It does not demonstrate a first installation on an air-gapped machine. Keep the model cache as well as the database; this experiment did not test recovery after removing either.\n\nRestarting the stock image with **no network interface at all** failed with `FATAL: port 0 is out of range`. The working isolation test uses an internal bridge, which provides an address without an external route.\n\n## Applying This to Your Documentation\n\nStart with short sections that retain their title, code, product version, and source link. This fixture set embeds one section per row; it does not establish a strategy for long manuals. Check model input limits before treating a whole page as one embedding.\n\nReplace the fixtures with your own troubleshooting sections and keep a small review set: exact identifiers, paraphrases, similar failures, contradictory inputs, and questions your documentation cannot answer. Compare the three result lists before changing fusion weights or candidate windows. In particular, the pool paraphrase shows how a document that vector search ranks sixth can still finish first after one lexical hit.\n\nLocal inference removes the hosted embedding API from this retrieval path, but local semantic search still costs CPU, memory, model storage, and relevance-review work. For documentation like these fixtures, offer exact-code matches separately from related pages so readers can tell which kind of result they are seeing. Compare hybrid rankings with each individual search: here, fusion moved the wrong page above the right one for the pool paraphrase.\n\nWhen you are finished, `docker compose down` stops this example and keeps its volume. Use `docker compose down -v` only when you want to delete this demo’s data and cached model. Neither command requires a global Docker cleanup.", "url": "https://wpnews.pro/news/local-hybrid-search-for-technical-documentation", "canonical_source": "https://manticoresearch.com/blog/local-documentation-hybrid-search/", "published_at": "2026-11-26 00:00:00+00:00", "updated_at": "2026-11-27 07:43:16.622634+00:00", "lang": "en", "topics": ["ai-search", "ai-tools", "machine-learning"], "entities": ["Manticore Search", "Xenova/all-MiniLM-L6-v2", "Docker", "Python"], "also_reported_by": [], "takeaway": "Running Manticore Search 29.9.0 with a local all-MiniLM-L6-v2 embedding model in a 2-CPU, 3 GiB container enables hybrid lexical and vector documentation search without a hosted embedding API, but the author's fixtures show the combined ranking can place the wrong page first in one test case.", "recommendation": {"advice": "Test hybrid lexical-plus-vector ranking against exact-code and symptom queries on your own fixtures before trusting it; the source's combined ranking returned the wrong top page in one case.", "playbook": "rag-retrieval", "playbook_url": "https://wpnews.pro/playbooks/rag-retrieval"}, "alternates": {"html": "https://wpnews.pro/news/local-hybrid-search-for-technical-documentation", "markdown": "https://wpnews.pro/news/local-hybrid-search-for-technical-documentation.md", "text": "https://wpnews.pro/news/local-hybrid-search-for-technical-documentation.txt", "jsonld": "https://wpnews.pro/news/local-hybrid-search-for-technical-documentation.jsonld"}}