A schema defines the data structure of an OpenSearch application. It specifies which tables store your data, how fields are typed within those tables, and which fields are indexed for full-text search or filtering.
All configuration lives under two top-level keys: tables (your data) and indexes (how that data is searchable).
Schema structure
| Field | Type | Description |
|---|---|---|
tables | Object | The tables in the application. Each key under tables is a table name. |
tables.* | Object | The definition of a table. See Table. |
indexes | Object | The index configuration for the application. See Index. |
Example
{
"tables": {
"main": {
"primaryTable": true,
"name": "main",
"fields": {
"id": {
"name": "id",
"type": "LITERAL",
"primaryKey": true
},
"title": {
"name": "title",
"type": "TEXT",
"primaryKey": false
},
"buy": {
"name": "buy",
"type": "INT",
"primaryKey": false
},
"cate_id": {
"name": "cate_id",
"type": "INT",
"primaryKey": false
},
"cate_name": {
"name": "cate_name",
"type": "LITERAL",
"primaryKey": false
}
}
}
},
"indexes": {
"searchFields": {
"id": {
"fields": [
"id"
]
},
"default": {
"fields": [
"title"
],
"analyzer": "chn_standard"
},
"cate_name": {
"fields": [
"cate_name"
]
}
},
"filterFields": [
"id",
"buy",
"cate_id",
"cate_name"
]
}
}Table
A table maps to a data source in your application. One table must be designated as the primary table.
| Field | Type | Description |
|---|---|---|
name | String | The name of the table. |
primaryTable | Boolean | Indicates whether the table is the primary table. |
fields | Object | The fields in the table. Each key under fields is a field name. |
fields.* | Object | The definition of a field. See Field. |
Example
{
"primaryTable": true,
"name": "main",
"fields": {
"id": {
"name": "id",
"type": "LITERAL",
"primaryKey": true
},
"title": {
"name": "title",
"type": "TEXT",
"primaryKey": false
},
"buy": {
"name": "buy",
"type": "INT",
"primaryKey": false
},
"cate_id": {
"name": "cate_id",
"type": "INT",
"primaryKey": false
},
"cate_name": {
"name": "cate_name",
"type": "LITERAL",
"primaryKey": false
}
}
}Field
A field represents a column in your table. Its type determines how the data is stored and which index operations are supported.
| Field | Type | Description |
|---|---|---|
name | String | The name of the field. |
type | String | The data type of the field. For supported types, see Schema of tables for Industry Algorithm Edition. |
primaryKey | Boolean | Indicates whether the field is a primary key field. |
joinWith | Array | The tables that are joined to external tables. |
Example
{
"type": "INT",
"name": "id",
"primaryKey": true,
"joinWith": ["other_table"]
}Index
The indexes object controls two types of indexing:
`searchFields`: Fields indexed for full-text search. Use these when you need to search across text content.
`filterFields`: Fields indexed as attributes for filtering and sorting. Use these for numeric comparisons, category filtering, and range queries.
| Field | Type | Description |
|---|---|---|
searchFields | Object | Index fields for full-text search. Each key is an index field name. |
searchFields.* | Object | The definition of a search index field. See Search field. |
filterFields | Array | Field names to index as attribute (filter) fields. |
Example
{
"searchFields": {
"default": {
"fields": [
"title"
],
"analyzer": "chn_standard"
},
"id": {
"fields": [
"id"
]
}
},
"filterFields": [
"id"
]
}Search field
A search field defines how one or more table fields are combined into a single full-text index.
| Field | Type | Description |
|---|---|---|
fields | Array | The list of index fields. |
analyzer | String | The name of the analyzer, such as a custom analyzer or built-in analyzer. For custom analyzers, see Custom analyzers. For built-in options, see Built-in analyzers. |
Example
{
"fields": ["title"],
"analyzer": "chn_standard"
}Built-in analyzers
Choose an analyzer based on the language and search behavior you need.
| Analyzer | Use when |
|---|---|
chn_standard | Searching Chinese text in general scenarios (e-commerce, news, documentation). |
simple | Searching content in specific scenarios using basic tokenization. |
chn_single | Searching by individual Chinese characters, such as for character-level matching. |
eng_standard | Searching English text with stemming — running matches run, runs, and ran. |
eng_nostem | Searching English text while retaining the roots of words. |
fuzzy | Tolerating minor spelling variations and typos in search queries. |
keyword | Matching the exact string without any tokenization — suitable for IDs, codes, and tags. |
chn_ecommerce | Searching product names, SKUs, and descriptions in Chinese e-commerce contexts. |
chn_film | Searching Chinese titles, cast names, and descriptions in video or media contexts. |
chn_scene_name | Recognizing and matching Chinese person names. |
chn_scene_org | Recognizing and matching Chinese organization names. |
first_letter | Searching by the first letter of each pinyin syllable (simple pinyin spelling). |
full_pinyin | Searching by the full pinyin spelling of Chinese characters. |
numeric | Performing range searches on numeric values. |
geo | Performing range searches based on geographical location. |
chn_it_content | Searching Chinese technical content, such as IT documentation and product descriptions. |