All Products
Search
Document Center

OpenSearch:Schema

Last Updated:Feb 20, 2023

Description

The schema of an OpenSearch application.

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"
        ]
    }
}

Structure

Field

Type

Description

tables

Object

The tables of the application.

tables.*

Object

The details of a table. For more information, see the "Table" section of this topic. The asterisk (*) indicates the name of the table.

indexes

Object

The indexes of the application. For more information, see the "Index" section of this topic.

Table

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
        }
    }
}

Structure

Field

Type

Description

fields

Object

The fields of the table.

fields.*

Object

The details of a field. For more information, see the "Field" section of this topic. The asterisk (*) indicates the name of the field.

primaryTable

Boolean

Indicates whether the table is the primary table.

name

String

The name of the table.

Field

Example

{
  "type": "INT",
  "name": "id",
  "primaryKey": true,
  "joinWith":["other_table"]
}

Structure

Field

Type

Description

type

String

The type of the field. For more information about field types, see Schema of tables for Industry Algorithm Edition.

name

String

The name of the field.

primaryKey

Boolean

Indicates whether the field is a primary key field.

joinWith

Array

The tables that are joined to external tables.

Index

Example

{
    "searchFields": {
      "default": {
        "fields": [
          "title"
        ],
        "analyzer": "chn_standard"
      },
      "id": {
        "fields": [
          "id"
        ]
      }
    },
    "filterFields": [
      "id"
    ]
}

Structure

Field

Type

Description

filterFields

Array

The list of attribute fields.

searchFields

Object

The information about index fields.

searchFields.*

Object

The details of an index field. For more information, see the "SearchField" section of this topic. The asterisk (*) indicates the name of the index field.

SearchField

Example

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

Structure

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 more information, see Custom analyzers and Built-in analyzers.

Built-in analyzers

Analyzer

Description

chn_standard

The general analyzer for Chinese text.

simple

The analyzer for specific scenarios.

chn_single

The analyzer for single Chinese characters.

eng_standard

The analyzer for stemming English words.

eng_nostem

The analyzer that retains the roots of English words.

fuzzy

The analyzer for fuzzy searches.

keyword

The analyzer for keywords.

chn_ecommerce

The analyzer for Chinese text from the E-commerce industry.

chn_film

The analyzer for Chinese text from videos.

chn_scene_name

The analyzer for person names in Chinese.

chn_scene_org

The analyzer for organization names in Chinese.

first_letter

The analyzer for simple pinyin spelling.

full_pinyin

The analyzer for full pinyin spelling.

numeric

The analyzer for searches by range.

geo

The analyzer for searches by the range of geographical locations.

chn_it_content

The analyzer for IT-related text.