Skip to main content

Introduction

A well-designed schema is crucial for accurate data extraction. This guide covers best practices, patterns, and anti-patterns for creating schemas that get the best results from Documind.

Schema Structure Basics

Minimum Viable Schema

Start simple and iterate:

Complete Schema Template

A production-ready schema with all recommended fields:

Best Practices

1. Write Descriptive Field Names

Why: Descriptive names help the AI understand what to extract and make your code more maintainable.

2. Always Include Descriptions

Why: Descriptions provide crucial context that improves extraction accuracy, especially for ambiguous fields.

3. Use Specific Field Descriptions

Why: Specific descriptions reduce ambiguity when documents contain multiple dates.

4. Specify Data Types Correctly

5. Mark Critical Fields as Required

Why: Required fields are flagged for review if confidence is low, ensuring accuracy where it matters most.

Working with Arrays

Simple Arrays

For lists of primitive values:

Array of Objects (Tables)

For structured lists like line items:

Working with Arrays

Define arrays to extract repeating data:

Working with Nested Objects

Simple Nesting

Group related fields:

Deep Nesting

For complex structures:
Avoid nesting deeper than 3-4 levels. Consider flattening or splitting into multiple extractions for very complex schemas.

Common Patterns

Invoice Schema

Receipt Schema

Form Schema

Examples in Descriptions

Include examples to guide extraction:

Common Mistakes

❌ Too Many Optional Fields

Problem: Review workflow won’t trigger even for poor extractions.
Solution: Mark at least 2-3 critical fields as required.

❌ Ambiguous Field Names

Problem: AI may extract the wrong data.
Solution: Use specific names: invoice_date, total_amount, invoice_number.

❌ Missing Descriptions

Problem: AI may confuse similar fields.
Solution: Always include descriptions.

❌ Wrong Data Types

Problem: You’ll get strings like “5” instead of numbers, making calculations fail.
Solution: Use correct types.

❌ Overly Complex Schemas

Problem: Harder to extract accurately, slower processing.
Solution: Flatten or split into multiple extractions.

Schema Testing

Iterative Development

  1. Start simple: Extract only 2-3 fields
  2. Test: Run on sample documents
  3. Validate: Check accuracy
  4. Expand: Add more fields
  5. Repeat: Until all needed data is extracted

A/B Testing

Test different schema approaches:

Next Steps

Prompt Design

Optimize extraction prompts for better results

Invoice Tutorial

Apply schema design to invoice processing

Core Concepts

Understand schemas in the context of Documind

API Reference

See the extraction API documentation