The schema defines the data structure of an OpenSearch application. It has two top-level objects: tables, which describe how your data is organized, and indexes, which control how that data is searched and filtered. Each field in a table must be registered in the schema before it can be searched or used as a filter.
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"
]
}
}This example defines one table (main) with five fields. The indexes object maps three of those fields to search indexes and lists four fields as filter (attribute) fields.
Structure
Schema
| Field | Type | Required | Description |
|---|---|---|---|
tables | Object | Yes | Table definitions. Each key is a table name; see Table for the structure of each value. |
indexes | Object | Yes | Index configuration. See Index. |
Table
Example
{
"primaryTable": true,
"name": "main",
"fields": {
"id": {
"name": "id",
"type": "LITERAL",
"primaryKey": true
},
"title": {
"name": "title",
"type": "TEXT",
"primaryKey": false
}
}
}Structure
| Field | Type | Required | Description |
|---|---|---|---|
name | String | Yes | The name of the table. |
primaryTable | Boolean | Yes | Specifies whether this table is the primary table. |
fields | Object | Yes | Field definitions. Each key is a field name; see Field for the structure of each value. |
Field
Example
{
"name": "json_nested",
"type": "NESTED",
"primaryKey": false,
"innerSchema": {
"job": {
"name": "job",
"type": "TEXT",
"primaryKey": false
},
"ssn": {
"name": "ssn",
"type": "LITERAL",
"primaryKey": false
}
}
}Structure
| Field | Type | Required | Description |
|---|---|---|---|
name | String | Yes | The name of the field. |
type | String | Yes | The field type: LITERAL, TEXT, INT, NESTED, or OBJECT. For details, see Application schema. |
primaryKey | Boolean | Yes | Specifies whether this field is the primary key. |
joinWith | Array | No | Links this field to linked external data tables. |
innerSchema | Object | No | The nested field structure. Required when type is OBJECT or NESTED. Supports multiple levels of nesting. |
Index
Example
{
"searchFields": {
"default": {
"fields": [
"title"
],
"analyzer": "chn_standard"
},
"id": {
"fields": [
"id"
]
}
},
"filterFields": [
"id"
]
}Structure
| Field | Type | Required | Description |
|---|---|---|---|
searchFields | Object | Yes | Full-text search index definitions. Each key is an index name; see SearchField for the structure of each value. |
filterFields | Array | Yes | The list of attribute fields. |
SearchField
Example
{
"fields": ["title"],
"analyzer": "chn_standard"
}Structure
| Field | Type | Required | Description |
|---|---|---|---|
fields | Array | Yes | The table fields included in this search index. |
analyzer | String | No | The analyzer to apply. For custom analyzers, see Custom analyzers. For built-in analyzers, see Built-in analyzers below and Built-in analyzers. |
Built-in analyzers
Chinese
| Analyzer | Description |
|---|---|
chn_standard | General Chinese analysis. Use for most Chinese full-text search fields. |
chn_single | Single Chinese character analysis. Use when each character is treated as an independent token. |
chn_ecommerce | Chinese e-commerce analysis. Optimized for product names and shopping queries. |
chn_film | Chinese video and entertainment analysis. Optimized for movie titles and media content. |
chn_scene_name | Chinese personal name analysis. |
chn_scene_org | Chinese organization name analysis. |
chn_it_content | IT content analysis for Chinese text. |
English
| Analyzer | Description |
|---|---|
eng_standard | English analysis with stemming. Matches word variants (e.g., "running" matches "run"). |
eng_nostem | English analysis without stemming. Matches exact word forms only. |
Language-agnostic and special-purpose
| Analyzer | Description |
|---|---|
simple | Simple analysis. Splits on whitespace and punctuation, lowercases tokens. |
keyword | Keyword analysis. Treats the entire field value as a single token. Use for exact-match fields. |
fuzzy | Fuzzy analysis. Generates token variants to support approximate matching. |
numeric | Numerical analysis. |
geo | Geolocation analysis. Use for geographic coordinate fields. |
first_letter | Simple pinyin spelling analysis. Indexes the first letter of each pinyin syllable. |
full_pinyin | Full pinyin spelling analysis. Indexes the complete pinyin transcription. |