All Products
Search
Document Center

OpenSearch:Schema

Last Updated:Apr 01, 2026

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

FieldTypeRequiredDescription
tablesObjectYesTable definitions. Each key is a table name; see Table for the structure of each value.
indexesObjectYesIndex 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

FieldTypeRequiredDescription
nameStringYesThe name of the table.
primaryTableBooleanYesSpecifies whether this table is the primary table.
fieldsObjectYesField 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

FieldTypeRequiredDescription
nameStringYesThe name of the field.
typeStringYesThe field type: LITERAL, TEXT, INT, NESTED, or OBJECT. For details, see Application schema.
primaryKeyBooleanYesSpecifies whether this field is the primary key.
joinWithArrayNoLinks this field to linked external data tables.
innerSchemaObjectNoThe 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

FieldTypeRequiredDescription
searchFieldsObjectYesFull-text search index definitions. Each key is an index name; see SearchField for the structure of each value.
filterFieldsArrayYesThe list of attribute fields.

SearchField

Example

{
    "fields": ["title"],
    "analyzer": "chn_standard"
}

Structure

FieldTypeRequiredDescription
fieldsArrayYesThe table fields included in this search index.
analyzerStringNoThe 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

AnalyzerDescription
chn_standardGeneral Chinese analysis. Use for most Chinese full-text search fields.
chn_singleSingle Chinese character analysis. Use when each character is treated as an independent token.
chn_ecommerceChinese e-commerce analysis. Optimized for product names and shopping queries.
chn_filmChinese video and entertainment analysis. Optimized for movie titles and media content.
chn_scene_nameChinese personal name analysis.
chn_scene_orgChinese organization name analysis.
chn_it_contentIT content analysis for Chinese text.

English

AnalyzerDescription
eng_standardEnglish analysis with stemming. Matches word variants (e.g., "running" matches "run").
eng_nostemEnglish analysis without stemming. Matches exact word forms only.

Language-agnostic and special-purpose

AnalyzerDescription
simpleSimple analysis. Splits on whitespace and punctuation, lowercases tokens.
keywordKeyword analysis. Treats the entire field value as a single token. Use for exact-match fields.
fuzzyFuzzy analysis. Generates token variants to support approximate matching.
numericNumerical analysis.
geoGeolocation analysis. Use for geographic coordinate fields.
first_letterSimple pinyin spelling analysis. Indexes the first letter of each pinyin syllable.
full_pinyinFull pinyin spelling analysis. Indexes the complete pinyin transcription.