CouchDB Mango queries use a custom _index when one exists
Answer: Queries use custom indexes specified using the _index endpoint, if available. If none is available, and the planner allows it, they fall back to the built-in _all_docs index, which can be slow.
_find and _index
_findthe POST endpoint that runs the query_indexthe endpoint that specifies custom indexes_all_docsthe built-in index used when no custom index is availableselectorthe JSON object describing criteria used to select documents
Find documents using a declarative JSON querying syntax. The selector is required. A custom index is specified using the _index endpoint.
Creating indices in Mango
The supported actions cover the four normal CRUD operations, plus one meta action that creates indices on the database. The API adds one URI endpoint onto the existing CouchDB HTTP API. Creating databases, authentication, and Map/Reduce views stay available; other existing behavior is still supported. The general principle is to stay simple for clients, and to give users a more natural conversion to Apache CouchDB.
See also
Claims
- id: C1 claim: Queries use custom indexes created at the _index endpoint when those indexes are available. source: S1 evidence: "Queries will use custom indexes, specified using the _index endpoint, if available."
- id: C2 claim: Without a usable custom index, a query may use the built-in _all_docs index, which can be arbitrarily slow. source: S1 evidence: "they use the built-in _all_docs index, which can be arbitrarily slow."
- id: C3 claim: Mango includes a meta action to create indices on the database, alongside the usual document actions. source: S2 evidence: "plus one meta action to create indices on the database."
Sources
- [S1] /{db}/_find. Apache CouchDB. https://docs.couchdb.org/en/stable/api/database/find.html . License: Apache-2.0. Accessed 2026-11-20.
- [S2] Mango README. Apache CouchDB. https://raw.githubusercontent.com/apache/couchdb/main/src/mango/README.md . License: Apache-2.0. Accessed 2026-11-20.
License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted). Sources: Apache CouchDB, /{db}/_find; Apache CouchDB, Mango README. Apache-2.0; Apache-2.0. Text was condensed and changed from the originals.
License: CC-BY-4.0 · Summary by iinventedlight (AI-assisted). Sources: Apache CouchDB, /{db}/_find; Apache CouchDB, Mango README. Apache-2.0; Apache-2.0.
Cite this
iinventedlight. 2026. "CouchDB Mango queries use a custom _index when one exists." iinventedlight Library, iil:note:jax44etf, version of 2026-11-20. https://iinventedlight.com/library/notes/couchdb-mango-indexes/. License: CC-BY-4.0.
@misc{iil_note_jax44etf,
author = {{iinventedlight}},
title = {{CouchDB Mango queries use a custom \_index when one exists}},
howpublished = {iinventedlight Library},
year = {2026},
date = {2026-11-20},
url = {https://iinventedlight.com/library/notes/couchdb-mango-indexes/},
note = {Permanent ID iil:note:jax44etf. License: CC-BY-4.0.},
}
Spotted a mistake? Use the MCP feedback tool or email hello@iinventedlight.com. Or Report a correction (no account needed).
Extra files beside this note
These files use this note's license, shown below. Paper extras retain their reproduction status; a link is not a reproduction.
- couchdb-mango-indexes.table.json (table; CC-BY-4.0)
- couchdb-mango-indexes.schema.json (schema; CC-BY-4.0)
For language models and agents: start at /llms.txt | /agents.md | /.well-known/agent-library.json. This page in Markdown: /library/notes/couchdb-mango-indexes.md.