06 Get Document Text
The node that turns a document ID into an actual string you can use
- session
- document_id_link
- collection_name_link
- json
- text
- text_length
- success
- refresh
- text_items
- selectable_items
- indexed_items
- item_count
If you're building anything with ZMongo documents - feeding extracted text into an LLM, logging a prompt, comparing document contents - this is the node you'll reach for constantly. "06 Get Document Text" takes a document ID and returns the text content as a plain STRING, which is the exact currency almost everything else in ComfyUI trades in.
How it works
It hits /api/text/{document_id} and extracts the text from the response. Here's where this node earns its keep: it has a fallback chain. If the text route returns nothing (which happens with Local File Store sessions, since they don't implement the route-based API), it falls back to loading the document generically and picks the best text field out of it - the code actually scores candidate fields for text quality and takes the winner, so you don't get a corrupt binary-looking value when a clean raw_text field exists one level deeper. If nothing at all resolves, it returns your fallback_text instead of crashing the graph. A node that refuses to hard-fail is a feature when you're mid-workflow.
The inputs that matter:
document_id(or the typeddocument_id_linkfrom a selector node) - which documentcollection_name- defaults todocuments, but if you ingested with "06 Ingest Text PDF / DOCX" intotext_documents, that's where the record lives, and this is where you tell the fallback to lookfallback_text- what to return when there's no text at all
Outputs: text (the string - wire this anywhere a prompt or text input goes), text_length (INT, handy for sanity checks), success, json (full payload), refresh, and text_items / the selectable tail for the list plumbing.
Install
cd ComfyUI/custom_nodes
git clone https://github.com/CentralFloridaAttorney/ComfyUI-ZMongo
Restart, or install "ComfyUI-ZMongo" via ComfyUI Manager.
Where people get burned
The collection mismatch is the #1 trap. Default collection_name is documents, but the ingest node's default is text_documents. If you ingested a file and then Get-Text returns empty, the document isn't lost - it's just in the other collection, and the fallback only finds it if you set collection_name to match. The node's own error payload literally tells you this.
Second, stale IDs. If you re-ran a list, saved a new document, and the ID you're passing was from an earlier run, the local store won't have it. Re-run "06 List Documents" and re-select. And don't wire a field path into the ID socket - that's what the guarded document_id_link outputs are for. When in doubt, read the json output; the failure payload lists exactly what it checked.
Inputs (8)
| Name | Type | Default | Description |
|---|---|---|---|
| session | ZMONGO_API_SESSION | — | |
| document_id | STRING | — | |
| document_prefix | STRING | /documents | — |
| document_id_linkopt | * | — | |
| collection_nameopt | STRING | documents | — |
| collection_name_linkopt | * | — | |
| fallback_textopt | STRING | — | |
| refresh_tokenopt | STRING | — |
Outputs (9)
| Name | Type | Description |
|---|---|---|
| json | STRING | — |
| text | STRING | — |
| text_length | INT | — |
| success | BOOLEAN | — |
| refresh | STRING | — |
| text_items | * | — |
| selectable_items | * | — |
| indexed_items | STRING | — |
| item_count | INT | — |