A schema is the blueprint for how Documind extracts specific information from your documents. It helps define the structure of the data you want.

What is a Schema?

A schema in Documind is a structured definition that tells the system what data to extract from a document. Think of it as a template or a map that ensures your extraction process retrieves the correct information in the desired format.

What can a schema do?

Schemas are used to:

  • Define the fields to extract.
  • Specify the type of data for each field (e.g., string, number, array).
  • Set the relationships between fields (e.g., nested arrays or objects).

Defining a Schema

You can define a schema in Documind as a JSON object. Each field in the schema includes the following:

name
string
required

A unique identifier for the field.

description
string
required

A brief explanation of what the field represents.

type
enum
required

The type of data. Options are: string, number, array, object.

children
array

Used when the field type is an array or object.


Example Schema

Here’s an example schema for a bank statement:

Bank statement schema
const schema = [
  {
    name: "accountNumber",
    type: "string",
    description: "The account number of the bank statement."
  },
  {
    name: "openingBalance",
    type: "number",
    description: "The opening balance of the account."
  },
  {
    name: "transactions",
    type: "array",
    description: "List of transactions in the account.",
    children: [
      {
        name: "date",
        type: "string",
        description: "Transaction date."
      },
      {
        name: "creditAmount",
        type: "number",
        description: "Credit Amount of the transaction."
      },
      {
        name: "debitAmount",
        type: "number",
        description: "Debit Amount of the transaction."
      },
      {
        name: "description",
        type: "string",
        description: "Transaction description."
      }
    ]
  },
  {
    name: "closingBalance",
    type: "number",
    description: "The closing balance of the account."
  }
]