Nodes/ComfyUI-ZMongo/06 Get Document Text
ComfyUI Node

06 Get Document Text

The node that turns a document ID into an actual string you can use

By CentralFloridaAttorney·Created 5 months ago·Updated 2 months ago· 1
06 Get Document Text
  • session
  • document_id_link
  • collection_name_link
  • json
  • text
  • text_length
  • success
  • refresh
  • text_items
  • selectable_items
  • indexed_items
  • item_count
document_id
document_prefix/documents
collection_namedocuments
fallback_text
refresh_token

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 typed document_id_link from a selector node) - which document
  • collection_name - defaults to documents, but if you ingested with "06 Ingest Text PDF / DOCX" into text_documents, that's where the record lives, and this is where you tell the fallback to look
  • fallback_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.

CategoryZMongo/03 Documents

Inputs (8)

NameTypeDefaultDescription
sessionZMONGO_API_SESSION
document_idSTRING
document_prefixSTRING/documents
document_id_linkopt*
collection_nameoptSTRINGdocuments
collection_name_linkopt*
fallback_textoptSTRING
refresh_tokenoptSTRING

Outputs (9)

NameTypeDescription
jsonSTRING
textSTRING
text_lengthINT
successBOOLEAN
refreshSTRING
text_items*
selectable_items*
indexed_itemsSTRING
item_countINT