> For the complete documentation index, see [llms.txt](https://docs.lingoql.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.lingoql.com/sub0/creating-database-models/indexing.md).

# Indexing

Sub0 uses declarative indexing. Set `indexable` or `fts` on a field, and Sub0 handles the database-specific index behavior.

***

### Standard indexes

To create a standard database index on a field, set `indexable` to `true`.

```json
{
  "email": {
    "type": "String",
    "indexable": true
  }
}
```

* Improves lookup performance for equality and range queries
* Supported across MongoDB, MySQL/MariaDB, and PostgreSQL
* Indexes are created automatically during model provisioning

***

### Full-text search

To enable full-text search on a field, set `fts` to `true`.

```json
{
  "content": {
    "type": "String",
    "fts": true
  }
}
```

* Enables text search across large string fields
* Optimized per database engine
* Can be combined with `indexable` when appropriate

***

### Combine indexing options

A field can be both indexed and searchable:

```json
{
  "title": {
    "type": "String",
    "indexable": true,
    "fts": true
  }
}
```

Use this for fields that are:

* Frequently filtered
* Frequently searched
* Central to query performance

***

### Index nested fields

Indexes can be applied to fields inside `JSON_OBJECT` structures.

```json
{
  "profile": {
    "type": "JSON_OBJECT",
    "properties": {
      "username": {
        "type": "String",
        "indexable": true
      }
    }
  }
}
```

Nested indexing behavior is handled automatically by Sub0.

***

### What Sub0 handles automatically

* Index creation and updates
* Database-specific index syntax
* Compatibility across supported databases
* Safe index application during provisioning

***

### Best practices

* Index fields used in filters, joins, or lookups
* Avoid indexing fields that are rarely queried or constantly updated unless necessary
* Use `fts` only for meaningful text search use cases

***

### Summary

* Use `indexable` for standard indexes
* Use `fts` for full-text search
* Declare indexes once — Sub0 handles the rest

Next, see [Anatomy of Models](/sub0/creating-database-models/anatomy-of-models.md) for the full field property reference.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.lingoql.com/sub0/creating-database-models/indexing.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
