Which documents hold this word? Count and list them by word
12 October 2026 · Semurg · 2 min read · Markdown
Last checked on r11.168.20261114.da3a8f8 (14 Nov 2026): every command below ran on a fresh node of that release. The current release is r11.173.20261116.3006727 (16 Nov 2026), and the commands have not been re-checked on it yet (how)
Search here means the plainest question a search index answers: which documents contain this word, and how many. Semurg keeps, for every word, a small record of how many documents hold it, and a list of which ones, so counting a word is one read and listing its documents is one sweep.
Index documents
Send each document's text under your own whole-number id. Run this once: indexing the same document again counts it twice.
export SEMURG_API_TOKEN=<your token>
curl -sS http://localhost:4000/v1/query \
-H "Authorization: Bearer $SEMURG_API_TOKEN" \
-H "Content-Type: application/json" \
-d '{"op": "index_documents",
"docs": [{"id": 900000000601, "body": "invoice export drops the currency column"},
{"id": 900000000602, "body": "the currency selector resets after login"},
{"id": 900000000603, "body": "export to spreadsheet is slow"}]}'Expected: three documents indexed
Words are runs of the letters a to z and the digits; anything else separates words, and there is no stemming, so export and exports are different words.
Count and list
term_docs counts the documents holding each of a list of words in one call; term_postings lists the documents holding one word, in ascending id order:
export SEMURG_API_TOKEN=<your token>
curl -sS http://localhost:4000/v1/query \
-H "Authorization: Bearer $SEMURG_API_TOKEN" \
-H "Content-Type: application/json" \
-d '{"op": "term_postings", "word": "currency"}'Expected: the two documents that mention currency
To find documents holding two words, list each word's documents and keep the ids both lists share. To change a document, delete it with the text it was indexed with, then index the new text; delete_documents takes the same shape as index_documents.
How it behaves
- A word's documents come back in id order.
- To combine words, combine their lists in your own code.
- Words are letters a to z.
- Index a document once: indexing the same document twice counts it twice, and a delete takes the text the document was indexed with.
Next
- Four kinds of data, one route: search beside objects, streams and places.
- Nearest vectors, filtered, then walked: a word as a filter on a vector search.
What Semurg is: Give Claude Code, Cursor and your other AI agents a memory that lasts: install Semurg on your own machine in one line.
Why use it: your agent recalls the facts it needs, each with its source, instead of re-reading the project.
What it solves today: agents that forget between sessions, and data that must stay on your own machines.
This post was written with AI assistance. Every result in it is checked against a published release or record before the post goes out.
How these commands were checked
Our test farm ran each of the 2 command blocks marked runnable, exactly as written, with the answer checked against the expectation printed under it, against a fresh node of the published release r11.168.20261114.da3a8f8. A post is published only when every one of them passed there.