Skip to main content
The search command group handles all search index operations, including creating, deleting, and populating indexes with post data. Supports multiple search backends (Meilisearch, LNX, Typesense).

Usage

python -m ayase_quart search <subcommand> [options]

Subcommands

index

Manage the lifecycle of search indexes. These operations affect the index structure itself, not the data within it.

index create

Create a new search index with the schema defined for your search provider.
python -m ayase_quart search index create
Confirmation prompt:
Create search index? (y/n):
Output:
Indexes created
Use cases:
  • Initial setup of search functionality
  • After changing search providers
  • Recovering from index corruption
Implementation details:
  • Calls sp.init_indexes() followed by sp.finalize() (src/ayase_quart/cli/search_cli.py:17-18)
  • Creates index schema without loading data
  • Safe to run on existing indexes (may fail if index already exists)

index delete

Remove all search index data. This is a destructive operation.
python -m ayase_quart search index delete
Confirmation prompt:
Delete search index? (y/n):
Output:
Index data wiped
This permanently deletes all indexed posts. You’ll need to run search load full to rebuild the index.
Use cases:
  • Switching search providers
  • Clearing corrupt index data
  • Reclaiming disk space before rebuilding
Implementation details:
  • Calls sp.posts_wipe() (src/ayase_quart/cli/search_cli.py:14)
  • Removes all documents from the index
  • Does not delete index schema/structure

index reset

Delete and immediately recreate the search index. Combines delete and create operations.
python -m ayase_quart search index reset
Confirmation prompt:
Reset search index? (y/n):
Output:
Index data reset
Use cases:
  • After schema changes in the code
  • Complete index refresh
  • Troubleshooting index issues
Implementation details:
  • Calls sp.posts_wipe(), sp.init_indexes(), sp.finalize() in sequence (src/ayase_quart/cli/search_cli.py:21-23)
  • Atomic operation (all steps complete together)

load

Populate the search index with post data from the database. Choose between full indexing or incremental updates.

load full

Index all posts from specified boards. This is a one-time bulk operation.
python -m ayase_quart search load full <BOARD> [<BOARD> ...]
BOARD
string
required
One or more board shortnames to index (e.g., a, vg, pol)
Example:
python -m ayase_quart search load full a vg
Output:
Loading posts from board: a
Indexed 1,523,891 posts from board: a
Loading posts from board: vg
Indexed 892,445 posts from board: vg
Complete
Use cases:
  • Initial index population
  • After running search index reset
  • Adding new boards to search
Implementation details:
  • Calls load_full(boards) (src/ayase_quart/cli/search_cli.py:31)
  • Processes all posts in database for specified boards
  • May take hours for large archives
  • Progress is printed to console

load incr

Index posts that aren’t in the search index yet. Runs continuously when using the --cron flag.
python -m ayase_quart search load incr [--cron SECONDS] <BOARD> [<BOARD> ...]
BOARD
string
required
One or more board shortnames to incrementally index
--cron
integer
Run every N seconds. Omit this flag to run once and exit.
Example (one-time):
python -m ayase_quart search load incr a vg
Example (continuous):
python -m ayase_quart search load incr --cron 300 a vg
Output (cron mode):
Indexing new posts...
Indexed 145 new posts
Waiting 300 seconds...
Indexing new posts...
Indexed 67 new posts
Waiting 300 seconds...
^C
Press Ctrl+C to gracefully stop the cron loop. The command will complete the current indexing cycle before exiting.
Use cases:
  • Keeping search index up-to-date with new posts
  • Running as a background service
  • Development/testing with frequent updates
Implementation details:
  • Calls incremental_index_single_thread() in a loop (src/ayase_quart/cli/search_cli.py:38-40)
  • When --cron is set, sleeps for specified seconds between runs
  • Gracefully handles KeyboardInterrupt (src/ayase_quart/cli/init.py:14)
  • Closes database and search connections on exit (src/ayase_quart/cli/search_cli.py:48-49)

Typical workflows

Initial setup

1

Create index

python -m ayase_quart search index create
Set up the index schema.
2

Load all posts

python -m ayase_quart search load full a vg pol
Populate with existing archive data.
3

Start incremental indexing

python -m ayase_quart search load incr --cron 300 a vg pol
Keep the index updated with new posts.

Switching search providers

1

Update configuration

Change your search provider in config.toml.
2

Reset index

python -m ayase_quart search index reset
Remove old index and create new one with new provider.
3

Reload data

python -m ayase_quart search load full a vg pol
Populate the new index.

Troubleshooting index issues

If search isn’t working correctly:
# Delete corrupt index
python -m ayase_quart search index delete

# Recreate fresh index
python -m ayase_quart search index create

# Reload all data
python -m ayase_quart search load full a vg

Performance considerations

Loading time depends on:
  • Total number of posts in the database
  • Search provider speed
  • Database performance
  • Network latency (if search provider is remote)
Expect 1-10 minutes per million posts.
For --cron interval, consider:
  • Post volume on your boards
  • Search provider indexing speed
  • System resource availability
Recommended: 300-600 seconds (5-10 minutes) for active boards.
The load full command loads posts in batches to avoid memory issues. The search provider maintains its own memory/disk requirements.

Error handling

ErrorCauseSolution
Index already existsRunning create on existing indexUse reset instead
Search provider unreachableConnection issuesCheck provider status and config
Board not foundInvalid board shortnameVerify board exists in database
KeyboardInterruptUser pressed Ctrl+CNormal shutdown, safe to restart

Supported search providers

The search commands work with any configured provider:

Meilisearch

Fast, typo-tolerant search

LNX

Lightweight, fast indexing

Typesense

Typo-tolerant, scalable search
Configure your provider in config.toml under the [search] section.

Running as a service

For production deployments, run incremental indexing as a system service:

systemd example

/etc/systemd/system/ayase-search.service
[Unit]
Description=Ayase Quart Search Indexer
After=network.target

[Service]
Type=simple
User=ayase
WorkingDirectory=/path/to/ayase_quart
ExecStart=/usr/bin/python3 -m ayase_quart search load incr --cron 300 a vg pol
Restart=always
RestartSec=10

[Install]
WantedBy=multi-user.target
Enable and start:
sudo systemctl enable ayase-search
sudo systemctl start ayase-search

Build docs developers (and LLMs) love