A one-command stack for the command-rec MongoDB backend, which scores inside
the database with $search + $vectorSearch. Those stages require the
mongot Search component — public preview in MongoDB Community 8.2+,
Linux-only, but it runs here in Docker on any host.
| Service | Image | Purpose |
|---|---|---|
mongod |
mongodb/mongodb-community-server:8.2.0-ubi9 |
Database, single-node replica set rs0 |
mongod-setup |
(same) | One-shot: rs.initiate() + create the mongotUser |
mongot |
mongodb/mongodb-community-search:0.53.1 |
Search/Vector indexing + query (gRPC on 27028) |
index-setup |
(same) | One-shot: create command_search + embedding_index indexes |
docker compose -f docker/docker-compose.yml up -d
# Watch the index-setup one-shot finish:
docker compose -f docker/docker-compose.yml logs -f index-setupindex-setup exits 0 once both Search indexes exist on command_rec.commands:
command_search—type: search, mapscommandas a stringembedding_index—type: vectorSearch,embedding, 384-dim, cosine
Verify:
docker exec cmdrec-mongod mongosh "mongodb://localhost:27017/command_rec" --quiet \
--eval 'db.commands.getSearchIndexes().forEach(i => print(i.name + " (" + i.type + ")"))'Teardown (removes data volumes too):
docker compose -f docker/docker-compose.yml down -vThe replica-set member is advertised as mongod:27017 (the only name mongod
recognizes as itself), so the host must use directConnection=true to skip
replica-set discovery (which would otherwise try to resolve mongod:27017):
# config.toml — works for the daemon AND tests, from the host on macOS/Linux
backend = "mongodb"
mongodb_connection_string = "mongodb://localhost:27017/?directConnection=true"Clients on the cmdrec-search Docker network instead use mongodb://mongod:27017/?directConnection=true.
This works for real shell usage on macOS via Docker Desktop — $search and
$vectorSearch (and embeddings) run fine through the published port. Verified
end-to-end with pipeline_hybrid_populates_embedding.
If you have a native MongoDB already listening on 127.0.0.1:27017 (e.g.
brew services start mongodb-community), host connections to localhost:27017
hit that server instead of this container. The native server has no mongot,
so $search/$vectorSearch fail with:
Error code 31082 (SearchNotEnabled): Using $search and $vectorSearch ... requires
additional configuration. Please connect to Atlas or an AtlasCLI local deployment.
…and queries look like they hit an empty database. Fix it by freeing the port:
brew services stop mongodb-community # or stop whatever owns :27017
lsof -nP -iTCP:27017 -sTCP:LISTEN # confirm only Docker is listening…or publish this stack on a different host port (edit docker-compose.yml
ports: ["27018:27017"]) and connect to mongodb://localhost:27018/?directConnection=true.
For everyday use you can of course also just use the SQLite backend (no Docker at all); this stack is for the MongoDB in-database pipeline.
docker-compose.yml— the four services + volumes +cmdrec-searchnetworkmongod.conf— pointsmongotHost/ search-index management atmongot:27028mongot.conf—syncSource→mongod:27017, gRPC server onmongot:27028pwfile— mongot user password (must bechmod 600, no trailing newline)setup-replica-set.sh— replica-set init +mongotUsercreationcreate-indexes.sh— collection + Search/Vector index creation (idempotent)