# es-search-relevance

Part of **ES**

# Elasticsearch Relevance Optimization Console Guide

## Operations Overview

| Operation | Console Entry | Prerequisites | Description |
|------|-----------|---------|------|
| Rerank Documents | Console > AI Search Open Platform > API Keys Management | Activated AI Search Open Platform, An API key for authentication | Configure reranking settings via the console to improve document relevance scoring |
| Configure NL2SQL Service | AI Search Open Platform > Instance Info > RAG Model Service Configuration > Create New Service | Access to the AI Search Open Platform console, Basic understanding of database schema and business data structure | Set up natural language to SQL translation with table definitions, training samples, and custom glossary rules |
| Manage Dictionaries in Console | Console > OpenSearch > Query Analysis > Dictionary Management | OpenSearch instance created, Access to the OpenSearch console | View built-in dictionaries and create custom intervention dictionaries for synonym, spelling correction, stop word, and term weight analysis |
| Create Tailored Retrieval Models | Console > Search Algorithm Center > Retrieval Configuration > Tailored Retrieval Models | Application must be in Advanced Edition, Dedicated application environment, Access to Search Algorithm Center in the console | Build and train custom retrieval models to enhance search relevance using application-specific data |

## Operation Steps

### Rerank Documents

**Navigation**: Console > AI Search Open Platform > API Keys Management

**Prerequisites**:
- Activated AI Search Open Platform
- An API key for authentication

1. Go to the AI Search Open Platform console  
   - Element: **AI Search Open Platform** (link) — top navigation panel

2. Navigate to API Keys Management  
   - Element: **API Keys Management** (link) — left navigation panel

> **Note**: This operation prepares authentication credentials required for calling the rerank API. Actual reranking is performed via SDK or API, not directly in the console.

### Configure NL2SQL Service

**Navigation**: AI Search Open Platform > Instance Info > RAG Model Service Configuration > Create New Service

**Prerequisites**:
- Access to the AI Search Open Platform console
- Basic understanding of database schema and business data structure

1. Navigate to the RAG Model Service Configuration page and click **Create New Service**  
   - Element: **Create New Service** (button) — top-right corner

2. Enter a service name such as `student_info_analysis`  
   - Element: **Service Name** (text_input) — main content area  
   - Notes: The name must be unique and follow naming conventions: lowercase letters, digits, underscores only, max 30 characters

3. Click **Next** to proceed to the next step  
   - Element: **Next** (button) — bottom of form

4. Configure basic table information using JSON format  
   - Element: **Basic Table Configuration** (textarea) — main content area  
   - Notes: Must include table name, columns with type, description, example, and value_mapping. Table and column names must start with lowercase letter and contain only lowercase letters, digits, or underscores.

5. Configure table join relationships using JSON array  
   - Element: **Table Join Configuration** (textarea) — main content area  
   - Notes: Format: `["table1.field=table2.field"]`

6. Click **Next** to proceed to custom rules and training samples  
   - Element: **Next** (button) — bottom of form

7. Add training samples with queries and corresponding SQL statements  
   - Element: **Training Sample Configuration** (textarea) — main content area  
   - Notes: Use JSON array format with 'query' and 'sql' fields

8. Add custom rules (glossary) for business-specific terms and concepts  
   - Element: **Custom Rule Configuration** (textarea) — main content area  
   - Notes: Use JSON array with 'key' and 'value' fields; e.g., `"Model student": "students.id <= 10"`

9. Click **Finish** to complete configuration and activate the service  
   - Element: **Finish** (button) — bottom of form

10. Click **Activate** to start activation process  
    - Element: **Activate** (button) — service list  
    - Notes: Status changes from Activating to Activated after validation

| Parameter | Type | Required | Options/Values | Description |
|-----------|------|----------|----------------|-------------|
| Service Name | text_input | Yes | — | Unique identifier for the NL2SQL service. Must be lowercase, alphanumeric, or underscore, max 30 characters. |
| Basic Table Configuration | textarea | Yes | — | JSON-formatted configuration of tables, including table name, columns with type, description, example, and value mapping. |
| Table Join Configuration | textarea | No | — | JSON array specifying join conditions between tables, e.g., `["students.class=schools.class"]` |
| Training Sample Configuration | textarea | No | — | JSON array of query-SQL pairs to improve model accuracy. Each object contains 'query' and 'sql' fields. |
| Custom Rule Configuration | textarea | No | — | JSON array of business-specific term definitions. Each object has 'key' (term) and 'value' (definition). |

### Manage Dictionaries in Console

**Navigation**: Console > OpenSearch > Query Analysis > Dictionary Management

**Prerequisites**:
- OpenSearch instance created
- Access to the OpenSearch console

1. Navigate to the Dictionary Management page  
   - Element: **Dictionary Management** (link) — left navigation panel

2. View the list of built-in dictionaries  
   - Element: **Built-in Dictionaries** (tab) — main content area  
   - Notes: Built-in dictionaries cannot be configured or deleted.

3. Create a custom intervention dictionary  
   - Element: **Create Custom Dictionary** (button) — top-right corner  
   - Notes: Custom dictionaries are used in combination with built-in dictionaries. Conflicts are resolved in favor of the custom dictionary entry.

### Create Tailored Retrieval Models

**Navigation**: Console > Search Algorithm Center > Retrieval Configuration > Tailored Retrieval Models

**Prerequisites**:
- Application must be in Advanced Edition
- Dedicated application environment
- Access to Search Algorithm Center in the console

1. Navigate to the Tailored Retrieval Models page  
   - Element: **Search Algorithm Center** (menu) — left-side navigation pane

2. Click on **Tailored Retrieval Models** in the left-side pane  
   - Element: **Tailored Retrieval Models** (menu) — left-side pane of Retrieval Configuration page

3. Select an application for which you want to create a tailored retrieval model  
   - Element: **Select Application** (dropdown) — top of the page

4. Click **Create** to start creating a new model  
   - Element: **Create** (button) — top-right corner

5. Configure model parameters including Model Name, Model Type, Basic Analyzer, Training Fields, and Normalization  
   - Element: **Model Name** (text_input) — form fields on the creation panel  
   - Notes: Basic Analyzer options include: Chinese - General Analyzer, Chinese - E-commerce Analyzer, IT - Content Analyzer, Industry - General Analyzer for Gaming, Industry - Educational Q&A Search, Industry - IT Content Analysis, and Industry - General Analyzer for E-commerce.

6. Click **OK** to save the model configuration  
   - Element: **OK** (button) — bottom of the configuration panel

7. Train the model after creation  
   - Element: **Train** (button) — Actions column on the Tailored Retrieval Models page  
   - Notes: The model starts in 'Unavailable' state. Training may take 1–2 days depending on data volume.

8. After training completes, go to **Analyzer Management** to create a custom analyzer  
   - Element: **Analyzer Management** (tab) — left-side navigation pane

9. Click **Create** under Text Analyzer tab  
   - Element: **Create** (button) — top-right corner of the Text Analyzer tab

10. Select **Tailored Model Analyzer** as the analyzer type and choose the trained model  
    - Element: **Tailored Model Analyzer** (dropdown) — analyzer type selection field  
    - Notes: Must select a HA3 engine instance and the corresponding tailored retrieval model.

11. Save the custom analyzer configuration  
    - Element: **Save** (button) — bottom of the form

12. Modify offline application settings to apply the custom analyzer  
    - Element: **Modify Offline Application** (button) — details page of the HA3 engine instance

13. Go to **Configure Index Schema** and assign the custom analyzer to an index  
    - Element: **Analysis Method** (dropdown) — index schema configuration section  
    - Notes: Select the model version to use.

14. Wait for reindexing to complete  
    - Notes: Reindexing process must finish before testing search results.

15. Test the model effects using the **Run search tests** page  
    - Element: **Run search tests** (link) — top navigation or test section  
    - Notes: Available after reindexing completes.

16. (Optional) Add an intervention entry via Dictionary Management  
    - Element: **Dictionary Management** (menu) — left-side pane of Retrieval Configuration page

17. Click **Add Intervention Entry** and fill in Query, Analyzer, and Tailored Retrieval Model  
    - Element: **Add Intervention Entry** (button) — top of the page

18. Click **Save** to finalize the intervention entry  
    - Element: **Save** (button) — bottom of the panel

19. View model details after training  
    - Element: **Details** (button) — Actions column

20. Click **View** in the Reference Rule column to see which rules reference the model  
    - Element: **View** (link) — Training History section

21. Test the model effect using test queries  
    - Element: **Test Text** (text_input) — Test Effect section  
    - Notes: Enter test query to evaluate term weights

22. Click **Effect Comparison** to compare model performance  
    - Element: **Effect Comparison** (button) — top of the Test Effect section  
    - Notes: Compares up to two models in typical cases

| Parameter | Type | Required | Options/Values | Description |
|-----------|------|----------|----------------|-------------|
| Model Name | text_input | Yes | — | Unique name for the tailored retrieval model. |
| Model Type | dropdown | Yes | Text Analyzer, Term Weight Analysis Model | Determines the behavior and configuration options displayed below |
| Basic Analyzer | dropdown | Yes | Chinese - General Analyzer, Chinese - E-commerce Analyzer, IT - Content Analyzer, Industry - General Analyzer for Gaming, Industry - Educational Q&A Search, Industry - IT Content Analysis, Industry - General Analyzer for E-commerce | Predefined analyzer based on industry or domain. |
| Training Fields | dropdown | Yes | — | One or more fields of TEXT or SHORT TEXT type used for training the model. |
| Normalization | checkbox | No | Uppercase to Lowercase, Traditional to Simplified Chinese, Full-width to Half-width Characters | Optional normalization rules applied during search; does not affect original data. |
| Query | text_input | Yes | — | The query to be analyzed by the intervention dictionary |
| Analyzer | dropdown | Yes | — | Specifies the analyzer used for processing the query |
| Tailored Retrieval Model | dropdown | Yes | — | Selects the specific tailored retrieval model to apply |

## FAQ

Q: Where do I find the Dictionary Management page in the OpenSearch console?  
A: Navigate to Console > OpenSearch > Query Analysis > Dictionary Management using the left-side navigation panel.

Q: Can I modify a tailored retrieval model after it has been trained?  
A: You cannot edit a trained model directly. You must create a new version with updated parameters and retrain it.

Q: What happens if my custom dictionary entry conflicts with a built-in dictionary entry?  
A: The custom dictionary entry takes precedence over the built-in one during query analysis.

Q: Do I need to reindex my data after applying a new tailored retrieval model?  
A: Yes. After assigning the custom analyzer to an index, you must trigger reindexing for the changes to take effect in search results.

Q: Is the NL2SQL service available for all OpenSearch instances?  
A: No. The NL2SQL service requires access to the AI Search Open Platform and is configured separately from standard OpenSearch instances.

## Pricing & Billing

### Billing Model
- **NL2SQL Service**: Billed per request (input + output counted as one call)
- **Tailored Retrieval Models**: Billed based on storage capacity, computing resources, and model training; only available in Advanced Edition dedicated applications
- **Dictionaries**: Free to use (no additional charge beyond base OpenSearch instance cost)

### Price Reference
| Tier | Input Price | Output Price |
|------|-------------|--------------|
| NL2SQL service | 0.0001 / | 0.0001 / |

> **Note**: Prices shown are in CNY and sourced verbatim from documentation.

### Free Tier
- NL2SQL service: 1000 (1,000 free requests per month)
- Dictionaries: No cost for using built-in or custom dictionaries in OpenSearch.
- Tailored Retrieval Models: No free tier mentioned

### Billing Notes
- NL2SQL: Billed per actual invocation. Minimum billing unit is 1 request. Each request includes both input and output.
- Tailored Retrieval Models: Charged based on storage capacity, computing resources, and model training. See billing methods in the Overview document.
- A maximum of 5 tailored models per instance is allowed.
- Elasticsearch engine instances do not support tailored retrieval models; only HA3 engine in Advanced Edition supports this feature.