---
updatedAt: 2026-10-01T17:11:41.000Z
agentTools:
  projectIndex: https://docs.sensible.so/llms.txt
---

# Field query object

How the SenseML Field query object works, including parameters and examples for extracting structured data from PDFs using layout-based and LLM-based methods.

A field is the basic *SenseML* query unit for extracting a piece of document data. SenseML is a query language that lets you extract structured data from documents, for example, from PDFs.  The output of a field is a JSON key-value pair that structures the extracted data.

A field uses a *method* to extract data.  SenseML contains *layout-based* and *large language model (LLM)-based* methods.

Here's a simple example of a layout-based field and its output:

#### Field query

```json
{
 "fields": [
   {
     /* find the first box in the document 
         containing the text 'rents'
        and return all the other text in the box */
     "anchor": "rents",
     "id": "rents_income",
     "method": {
       "id": "box",
     }
   }
 ]
}
```

#### Extracted field output

```json
{
  "rents_income": {
    "type": "string",
    "value": "$ 4,200"
  }
}
```

<Image alt="Click to enlarge" border={false} src="https://raw.githubusercontent.com/sensible-hq/sensible-docs/v0/assets/images/final/box_1099.png" />

The following example shows the syntax for all the top-level parameters of the Field object:

For more information, see the following sections.

[**Parameters**](https://docs.sensible.so/docs/field-query-object#parameters)\
[**Examples**](https://docs.sensible.so/docs/field-query-object#examples)\
[**Notes**](https://docs.sensible.so/docs/field-query-object#notes)

# Parameters

The Field query object has the following top-level parameters:

| Parameter             | Value                                                        | Description for layout-based methods                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  | Description for LLM-based methods                                                                                                                                                                                                                                      |
| --------------------- | ------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| id (**required**)     | string                                                       | Sensible uses the ID as the key in the structured key/value output. In the API response, this output is in the `parsed_document` object.<br /><br />If a field fails and returns null, you can specify a backup, or fallback field to target the same data with a different method. To specify fallbacks between fields, specify consecutive fields that use the same ID. For more information, see [Fallback fields](https://docs.sensible.so/docs/fallbacks).                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 | Same                                                                                                                                                                                                                                                                   |
| anchor                | string, [Match object](https://docs.sensible.so/docs/match), or array of Match objects | **Required**<br /> Matched text that narrows down the location of the target data to extract. <br /> For more information, see [Anchor object](https://docs.sensible.so/docs/anchor).                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           | **Optional** <br />If the matched text is present anywhere in the document, Sensible runs the method on the whole document, otherwise it returns `null`.   For more information, see [Anchor object](https://docs.sensible.so/docs/anchor).                                                      |
| method (**required**) | object                                                       | Defines how to spatially expand out from the anchor and extract the target data. Use for documents that have a relatively consistent spatial layout. For example, 1040 forms have relatively consistent layout. For more information, see [Layout-based methods](https://docs.sensible.so/docs/layout-based-methods).                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           | Describes the contents of the target data to extract in natural-language prompts for an LLM. Use for documents that have a relatively inconsistent spatial layout, for example, legal contracts. For more information, see [LLM-based methods](https://docs.sensible.so/docs/llm-based-methods). |
| type                  | see [Types](https://docs.sensible.so/docs/types)                                       | The data type to extract, for example, a currency, an address, or a custom type you define. This structured output includes the type information. If the field captures other data in addition to the data matching the type, Sensible suppresses the additional data from the output. For more information, see [Types](https://docs.sensible.so/docs/types).                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  | same                                                                                                                                                                                                                                                                   |
| match                 | `first`,`last`,`all`, `allWithNull`,`mostFrequent`           | If there are multiple anchors, specifies which one to use to extract output for layout-based methods. <br /> <br />- `first`  specifies the first anchor in the document that returns non-null output.<br /><br />- `last` specifies the last anchor in the document that returns non-null output.<br /><br />- `all` matches all anchors and returns non-null extracted output under a single key. <br />- `allWithNull`  matches all anchors and returns extracted output, including null output, under a single key. For example, use this option if you're using the [Zip computed field method](https://docs.sensible.so/docs/zip) to zip together parallel arrays, where array elements can be nulls. For an example, see [Zip](https://docs.sensible.so/docs/zip#match-with-null-zip).<br /><br />- `mostFrequent` matches all anchors, extracts the corresponding output, then returns the most frequently occurring non-null output. This is useful for OCR text, like poor-quality scans or photographs. For example, a scanned document repeats a box titled `1 Wages` four times with the same dollar value, `21850.20`. Due to OCR errors, the extracted outputs are `21050.20`, `21850.20`, `21850.20` and `21850.58`.  This option returns the most frequent, and therefore the mostly likely correct output,  `21850.20`. | not applicable                                                                                                                                                                                                                                                         |

# Examples

## Example 1

The following example shows a layout-based field and an LLM-based field.

**Config**

```json
{
  "fields": [
    {
      /* LAYOUT-BASED EXAMPLE */
      "id": "name_of_output_key",
      /* an anchor is some text to match. define complex anchors using match
         arrays 
      */
      "anchor": "here's an anchor",
      /* this method uses spatial information 
         to locate the target data relative to the anchor 
      */
      "method": {
        "id": "label",
        /* target data is below the anchor */
        "position": "below"
      }
    },
    /* LLM-BASED EXAMPLE */
    {
      "id": "overview_table",
      "method": {
        /* this method uses LLMs to search
           for your target data based on your prompts ("descriptions") 
        */
        "id": "nlpTable",
        "description": "table describing SenseML",
        "columns": [
          {
            "id": "attribute",
            "description": "attribute of SenseML",
          },
          {
            "id": "description",
            "description": "description ",
          }
        ]
      }
    }
  ]
}
```

**Example document**

The following image shows the example document used with this example config:

<Image alt="Click to enlarge" border={false} src="https://raw.githubusercontent.com/sensible-hq/sensible-docs/v0/assets/images/final/basic_field.png" />

| Example document | [Download link](https://raw.githubusercontent.com/sensible-hq/sensible-docs/v0/assets/pdfs/basic_field.pdf) |
| ---------------- | ----------------------------------------------------------------------------------------------------------- |

**Output**

```json
{
  "name_of_output_key": {
    "type": "string",
    "value": "Below the matching anchor, this is the data to extract. The anchor is a label for this data."
  },
  "overview_table": {
    "columns": [
      {
        "id": "attribute",
        "values": [
          {
            "value": "key concepts",
            "type": "string"
          },
          {
            "value": "key method categories",
            "type": "string"
          }
        ]
      },
      {
        "id": "description",
        "values": [
          {
            "value": "Fields, anchors, and methods",
            "type": "string"
          },
          {
            "value": "LLM-based, layout-based, and computed",
            "type": "string"
          }
        ]
      }
    ],
    "title": {
      "type": "string",
      "value": "SenseML overview"
    }
  }
}

```

# Next

The Field object contains:

* [Anchor object](https://docs.sensible.so/docs/anchor)
* [Method object](https://docs.sensible.so/docs/method)