# General

# How do I re-index documents?

Aero automatically manages indexing changes to documents.

For example, if a product's stock level changes the document is updated to reflect the current version.

Adding and removing documents is also taken care of for you, sparing the need to schedule in daily tasks to update the store's entire catalog. However, in cases where a large amount of data has been manually changed, or an addition to the document structure has been made, a re-index of all documents can be carried out using the following command:

```bash
php artisan aero:search:reindex
```

If there have only been modifications to a certain document (for example, only the listing document structure has been extended) then the document `type` can be passed as an option, which will only re-index the documents with the provided type.

The available types correspond to the names of the elastic documents, `listing`, and `product`:

```
// Only listings
php artisan aero:search:reindex --type=listing

// Only products
php artisan aero:search:reindex --type=product
```

# How do I re-build documents?

At times (especially during the development phase of a store build), it may be necessary to delete and documents and freshly index them. This process can be achieved using the following command:

```
php artisan aero:search:rebuild
```

Due to the nature of how this process runs, there will be a temporary period where there are no listings or products shown.

This can be circumvented by using the `--swap` option:

```
php artisan aero:search:rebuild --swap
```

This will aliases to ensure there is no downtime, it works by creating a new alias, rebuilding the data for that alias and only after it is complete swapping over to that alias. This means there will be no period where there are no listings or products shown.