# rds-text

Part of **RDS**

# ApsaraDB RDS Text and Vector Search Console Guide

## Operations Overview

| Operation | Console Navigation Path | Prerequisites | Description |
|----------|-------------------------|---------------|-------------|
| Perform Fuzzy Search | RDS > Instances > Select Instance > Database Management > SQL Console | - RDS for PostgreSQL instance with minor engine version 20230830+ (PG 10–15), 20250830+ (PG 17), or unrestricted (PG 16)<br>- `pg_bigm` added to `shared_preload_libraries` | Use pg_bigm extension for fuzzy and similarity-based text matching, especially for short keywords and non-alphabetic languages |
| Enable Chinese Full Text Search | RDS > Instances > Select Instance > Database Management > SQL Console | - PostgreSQL 10 or later<br>- Minor engine version 20230830+ (20241030+ for PG 17)<br>- `zhparser` added to `shared_preload_libraries` | Configure zhparser for semantic Chinese word segmentation and full-text search |
| Integrate Elasticsearch with PostgreSQL | RDS > Instances > Select Instance > Database Management > SQL Console | - PostgreSQL 11 with minor engine version 20230830 or later | Use ZomboDB extension to integrate Elasticsearch search capabilities into PostgreSQL via SQL |
| Create Vector Table | Console > RDS > Instances > [Instance ID] > Plugins | - PostgreSQL 14 or later<br>- Minor engine version 20230430+ (20241030+ for PG 17)<br>- Privileged account created | Install pgvector extension to store and query high-dimensional vectors for AI similarity search |

## Step-by-Step Instructions

### Perform Fuzzy Search

**Navigation**: RDS Console > Instances > Select Instance > Database Management > SQL Console

**Prerequisites**:
- An RDS for PostgreSQL instance with minor engine version 20230830 or later (PostgreSQL 10–15), 20250830 or later (PostgreSQL 17), or no restrictions (PostgreSQL 16)
- The `pg_bigm` extension added to the `shared_preload_libraries` parameter

1. Navigate to the RDS console and select your PostgreSQL instance  
   - Element: **Instances** (menu) — left navigation panel

2. Click on the instance name to open its details page  
   - Element: **Instance Name** (link) — instance list

3. Go to the Database Management section and open the SQL Console  
   - Element: **SQL Console** (tab) — main content area

> Note: All subsequent operations (e.g., creating GIN indexes, running `LIKE '%...%'` queries with similarity thresholds) are executed as SQL statements in the SQL Console. Click the **Run** button after entering each command.

---

### Enable Chinese Full Text Search

**Navigation**: RDS Console > Instances > Select Instance > Database Management > SQL Console

**Prerequisites**:
- RDS instance runs PostgreSQL 10 or later
- Minor engine version is 20230830 or later (20241030 for PostgreSQL 17)
- `zhparser` added to `shared_preload_libraries` parameter

1. Open the SQL Console in the RDS console  
   - Element: **SQL Console** (link) — Database Management section

2. Run the `CREATE EXTENSION zhparser;` statement  
   - Element: **Run** (button) — bottom of the SQL editor

3. Create a text search configuration named `testzhcfg`  
   - Element: **Run** (button) — bottom of the SQL editor

4. Add mappings for token types n,v,a,i,e,l to the simple dictionary  
   - Element: **Run** (button) — bottom of the SQL editor

5. Create a GIN index on the target column using `to_tsvector`  
   - Element: **Run** (button) — bottom of the SQL editor

> Note: After setup, use `to_tsvector('testzhcfg', text)` and `to_tsquery('testzhcfg', 'query')` in your queries for Chinese full-text search.

---

### Integrate Elasticsearch with PostgreSQL

**Navigation**: RDS Console > Instances > Select Instance > Database Management > SQL Console

**Prerequisites**:
- An RDS instance running PostgreSQL 11 with minor engine version 20230830 or later

1. Navigate to the RDS console and select your PostgreSQL 11 instance  
   - Element: **Instances** (menu) — left navigation panel

2. Click the instance ID to access its management page  
   - Element: **Instance ID** (link) — instance list

3. Open the SQL Console under Database Management  
   - Element: **SQL Console** (tab) — main content area

4. Execute `CREATE EXTENSION zombodb;` to install the extension  
   - Element: **Run** (button) — bottom of the SQL editor

5. Create a ZomboDB index using `USING zombodb` clause  
   - Element: **Run** (button) — bottom of the SQL editor

> Note: Queries use standard SQL with ZQL (ZomboDB Query Language) syntax embedded in `WHERE` clauses. No additional UI steps beyond SQL execution are required.

---

### Create Vector Table

**Navigation**: Console > RDS > Instances > [Instance ID] > Plugins

**Prerequisites**:
- PostgreSQL major engine version 14 or later
- Minor engine version 20230430 or later (for PostgreSQL 17: 20241030 or later)
- Privileged account created for the instance

1. Go to the Instances page and select your instance's region, then click the instance ID  
   - Element: **Instances** (link) — top navigation bar

2. Click on the **Plugins** tab in the left-side navigation pane  
   - Element: **Plugins** (tab) — left-side navigation pane

3. Find the **pgvector** extension and click **Install**  
   - Element: **Install** (button) — pgvector row in the table  
   - Notes: The extension is successfully installed when the instance status changes from 'INS_MAINTAINING' to 'Running'.

4. In the installation dialog, select the target database and privileged account, then click **Install** again  
   - Element: **Install** (button) — dialog box

> Note: After installation, use the SQL Console to create tables with `vector` columns and build HNSW or IVF indexes for similarity search.

## FAQ

Q: Where do I run SQL commands to enable text or vector search extensions?  
A: Use the **SQL Console** under **Database Management** in your RDS instance details page. All extension setup (e.g., `CREATE EXTENSION`) is done via SQL.

Q: Can I install pgvector through the SQL Console like other extensions?  
A: No. pgvector must be installed via the **Plugins** tab in the RDS console. Other extensions like zhparser and pg_bigm are enabled via SQL after ensuring they’re in `shared_preload_libraries`.

Q: What permissions are required to install extensions or create indexes?  
A: You need a **privileged account** (typically the initial account created during instance setup) with superuser-like privileges in RDS for PostgreSQL.

Q: Do I need to restart my RDS instance after adding an extension to `shared_preload_libraries`?  
A: Yes. Modifying `shared_preload_libraries` requires a **configuration change and instance restart**, which can be done in the **Parameters** section of the console.

Q: Can I modify the text search configuration (e.g., for zhparser) after creation?  
A: Yes. You can alter configurations using SQL commands like `ALTER TEXT SEARCH CONFIGURATION ... ADD MAPPING`, but you may need to rebuild indexes for changes to take effect.

## Pricing & Billing

### Billing Model
All text and vector search extensions (pg_bigm, zhparser, ZomboDB, pgvector) are billed as part of the underlying RDS instance. There are no separate per-query or per-extension charges.

### Price Reference
- Standard RDS instance pricing applies (per instance-hour)
- For pgvector usage involving external embedding generation (if applicable):  
 - Input: 0.002 /tokens 
 - Output: 0.003 /tokens

### Free Tier
- Monthly free quota: 1 million tokens (for embedding-related operations, if applicable)

### Quota Limits
- Maximum indexable column size for pg_bigm: 107,374,180 bytes (~102 MB)
- pgvector QPS limit: 100 queries per second

### Billing Notes
- Extension usage is included in standard RDS instance costs. No additional charges for pg_bigm, zhparser, or ZomboDB.
- Async tasks (e.g., batch embedding) are billed upon completion.
- Always refer to the official ApsaraDB RDS pricing page for the most current rates.