> ## Documentation Index
> Fetch the complete documentation index at: https://nikita-shkoda.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Indexing

> Fastest ways to build documents into a collection.

## Related links

* <a href="/projects/search-engine-for-typesense/v30/indexer">Indexer</a>
* <a href="/projects/search-engine-for-typesense/v30/cli">CLI</a>
* <a href="/projects/search-engine-for-typesense/v30/observability">Observability</a>
* <a href="/projects/search-engine-for-typesense/v30/troubleshooting">Troubleshooting</a>

Use this page when you need the quickest way to index a collection.

<Note>
  Define <code>index do ... map</code> in your model first. See
  <a href="/projects/search-engine-for-typesense/v30/indexer">Indexer</a>.
</Note>

## Fastest ways to index

<Steps>
  <Step title="CLI (single collection)">
    ```bash theme={null}
    rails 'search_engine:index:rebuild[books]'
    ```
  </Step>

  <Step title="Ruby (single or multiple collections)">
    ```ruby theme={null}
    SearchEngine::Book.index_collection
    SearchEngine::Bulk.index_collections(:books, :publishers)
    SearchEngine::Bulk.index_all
    ```

    <Tip>
      Use <code>partition:</code> to rebuild specific partitions.
    </Tip>
  </Step>
</Steps>

## Optional: auto-sync on changes

```ruby app/models/book.rb theme={null}
class Book < ApplicationRecord
  include SearchEngine::ActiveRecordSyncable

  search_engine_syncable on: %i[create update destroy]
end
```

## Next steps

* See <a href="/projects/search-engine-for-typesense/v30/indexer">Indexer</a> for mapping
  options and batch tuning.
* Use <a href="/projects/search-engine-for-typesense/v30/observability">Observability</a>
  to monitor rebuilds.
