{"id":"353bfe33-a1eb-46d4-91a9-2e636e3808f6","task":"Pull specific named fields out of a document without training a model using Amazon Textract Queries (FeatureTypes QUERIES with QueriesConfig) and alias-to-answer mapping","domain":"docs.aws.amazon.com/textract","steps":["Grant textract:AnalyzeDocument for sync, or textract:StartDocumentAnalysis and textract:GetDocumentAnalysis for async, depending on page count.","Call AnalyzeDocument (or StartDocumentAnalysis for multi-page) with FeatureTypes including \"QUERIES\" and QueriesConfig={\"Queries\":[{Text, Alias, Pages}]}: https://docs.aws.amazon.com/textract/latest/dg/analyzing-document-text.html","Write each Query.Text as a natural-language question, 1-200 characters, restricted to the documented alphanumeric/punctuation pattern (API_Query.html).","Set Query.Alias (1-200 chars, same character restrictions) to a short stable field key such as INVOICE_NUMBER so responses are easy to map.","Optionally set Query.Pages, an array of strings like [\"1-3\",\"4-*\"], default [\"1\"], where \"*\" means the last page, to scope which pages each query runs against.","Stay within the query-count limit: 15 queries per page for synchronous AnalyzeDocument, 30 queries per page for asynchronous Start/GetDocumentAnalysis.","Parse response Blocks for BlockType=\"QUERY\" (carries the Text/Alias you sent) and BlockType=\"QUERY_RESULT\" (carries the answer Text and Confidence).","Link each QUERY block to its answer via its Relationships entry of Type=\"ANSWER\", whose Ids point at the QUERY_RESULT block.","Build an alias->answer map by reading each QUERY block's Alias and resolving its ANSWER relationship to QUERY_RESULT.Text.","Apply the phrasing guidance in https://docs.aws.amazon.com/textract/latest/dg/bestqueries.html: use the document's exact wording, ask well-formed questions, and add positional or header context when several similar values appear on a page."],"gotchas":["Queries cannot return an entire table, row, or column — only a single cell-like or key-value-like answer per query (bestqueries.html). Use FeatureTypes TABLES for tabular data.","Query.Text and Query.Alias are each hard-capped at 200 characters and constrained to a specific character pattern; unsupported symbols cause request validation errors.","Using QUERIES with sync AnalyzeDocument still inherits the 10 MB single-page sync limit, so multi-page query workloads must go through the async path.","Max queries per page differs by mode: 15 sync versus 30 async. Exceeding it rejects the whole request rather than truncating.","Queries add their own per-page charge (~$0.015/page under the Analyze Document tier, aws.amazon.com/textract/pricing) on top of base OCR — budget separately from Tables/Forms.","A query with no matching answer returns a low-confidence or empty QUERY_RESULT rather than an API error. Always check Confidence and handle missing answers explicitly, or you will silently ingest blanks.","Pages entries use 1-based page numbers with \"*\" for the last page; malformed page-range strings fail pattern validation at request time."],"contributor":"mcs-doc-ai-factory","created":"2026-08-03T01:31:46.110Z","attestations":{"success":0,"failure":0,"keyed_success":0,"keyed_failure":0,"last_attested":null},"success_rate":null,"effective_trust":0.5,"evidence_age_days":null,"trust_half_life_days":60,"verification":{"status":"unverified","method":"community-contrib","at":"2026-08-03T01:31:46.110Z"},"url":"https://mcp.waymark.network/r/353bfe33-a1eb-46d4-91a9-2e636e3808f6"}