Skip to content

Commit

Permalink
Incremental changes
Browse files Browse the repository at this point in the history
  • Loading branch information
dwdougherty committed Jan 24, 2025
1 parent 7102a3b commit 2a182dd
Showing 1 changed file with 36 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,43 @@ categories:
linkTitle: RQE index management
weight: 3
---
## Introduction to managing Redis Query Engine indexes

#### 1. Plan your indexes strategically
The Redis Query Engine (RQE) is a powerful tool for executing complex search and query operations on structured, semi-structured, and unstructured data. Indexes are the backbone of this functionality, enabling fast and efficient data retrieval.
Proper management of these indexes is essential for optimal performance, scalability, and resource utilization.

This guide outlines best practices for managing RQE indexes throughout their lifecycle. It provides recommendations on:

- Planning and creating indexes to suit your query patterns.
- Using index aliasing to manage schema updates and minimize downtime.
- Monitoring and verifying index population to ensure query readiness.
- Optimizing performance through query profiling and memory management.
- Maintaining and scaling indexes in both standalone and clustered Redis environments.
- Versioning, testing, and automating index management.

## Why index management matters

Indexes directly impact query speed and resource consumption.
Poorly managed indexes can lead to increased memory usage, slower query times, and challenges in maintaining data consistency.
By following the strategies outlined in this guide, you can:

- Reduce operational overhead.
- Improve application performance.
- Ensure smooth transitions during schema changes.
- Scale efficiently with your growing datasets.

## Plan your indexes strategically
- Understand your query patterns: before creating indexes, analyze your expected query patterns to ensure indexes are optimized for performance.
- Avoid over-indexing: indexing every field increases memory usage and can slow down updates. Only index fields essential for your queries.
- Choose appropriate index types: use the correct field types (`TEXT`, `TAG`, `NUMERIC`, `GEO`, or `VECTOR`) for your data to maximize efficiency.

#### 2. Index creation
- Atomic creation: use the `FT.CREATE` command to atomically define an index schema.
## Index creation
- Use the [`FT.CREATE`]({{< baseurl >}}/commands/ft.create) command to define an index schema.
- Field weighting: assign weights to `TEXT` fields to prioritize certain fields in full-text search results.
- Prefix optimization: leverage the `PREFIX` option to restrict indexing to keys with specific patterns.
- Data loading strategy: load data into Redis before creating an index when working with large datasets. Use the `ON HASH` or `ON JSON` options to match the data structure.

#### 3. Index aliasing
## Index aliasing
- What is index aliasing?
- Aliases act as abstracted names for indexes, allowing applications to reference the alias instead of the actual index name. This simplifies schema updates and index management.
- Use cases for index aliasing:
Expand All @@ -35,9 +59,9 @@ weight: 3
- Update an alias: `FT.ALIASUPDATE my_alias new_index`
- Remove an alias: `FT.ALIASDEL my_alias`

#### 4. Monitoring index population
## Monitoring index population
- Check document count:
- Use the `FT.INFO` command to monitor the `num_docs` field, ensuring all expected documents are indexed.
- Use the `FT.INFO` command to monitor the `num_docs` field, to check that all expected documents are indexed.
- Example:
```bash
FT.INFO my_new_index
Expand Down Expand Up @@ -69,28 +93,28 @@ weight: 3
print("Index is still populating...")
```
#### 5. Monitoring index performance
## Monitoring index performance
- Query profiling: use the `FT.PROFILE` command to analyze query performance and identify bottlenecks.
- Memory usage: regularly monitor memory usage with the `INFO memory` and `FT.INFO` commands to detect growth patterns and optimize resource allocation.
- Search query logs: enable query logging for better insights into how indexes are utilized.
#### 6. Index maintenance
## Index maintenance
- Reindexing: if schema changes are required, create a new index with the updated schema and reassign the alias once the index is ready.
- Expire old data: use Redis key expiration or TTLs to automatically remove outdated records and keep indexes lean.
#### 7. Scaling and high availability
## Scaling and high availability
- Sharding considerations: in a clustered Redis setup, ensure indexes are designed with key distribution in mind to prevent query inefficiencies.
- Replication: test how indexes behave under replica promotion to ensure consistent query behavior across nodes.
- Active-Active support: if using Redis in an active-active setup, validate how index updates propagate to avoid inconsistencies.
#### 8. Versioning and testing
## Versioning and testing
- Index versioning: when changing schemas, create a new version of the index alongside the old one and migrate data progressively.
- Staging environment: test index changes in a staging environment before deploying them to production.
#### 9. Cleaning up
## Cleaning up
- Index deletion: use the `FT.DROPINDEX` command to remove unused indexes and free up memory. Be cautious with the `DD` (Delete Documents) flag to avoid unintended data deletion.
- Monitoring orphaned keys: Ensure no keys remain that were previously associated with dropped indexes.
#### 10. Documentation and automation
## Documentation and automation
- Maintain clear index schemas: document your index configurations to facilitate future maintenance.
- Automate index management: use scripts or orchestration tools to automate index creation, monitoring, and cleanup.

0 comments on commit 2a182dd

Please sign in to comment.