All Products
Search
Document Center

OpenSearch:Index schema

Last Updated:Mar 03, 2023

Index schema

An index schema consists of index fields and attribute fields. Index fields are used in data searches after the analysis is performed on fields of TEXT types. Attribute fields are used in data statistics, sort, filtering, and aggregation.

Fields of the following types can be configured as index fields:

INT, INT_ARRAY, TEXT, SHORT_TEXT, LITERAL, LITERAL_ARRAY, TIMESTAMP, and GEO_POINT

Fields of the following types cannot be configured as index fields:

FLOAT, FLOAT_ARRAY, DOUBLE, and DOUBLE_ARRAY

Fields of the following types can be configured as attribute fields:

INT, INT_ARRAY, LITERAL, LITERAL_ARRAY, FLOAT, FLOAT_ARRAY, DOUBLE, DOUBLE_ARRAY, TIMESTAMP, and GEO_POINT

Fields of the following types cannot be configured as attribute fields:

TEXT and SHORT_TEXT

Composite index

A composite index is an index that is created on multiple fields of the TEXT or SHORT_TEXT type. A search that is conducted by using a composite index slightly differs from a search that is conducted by using multiple indexes and the OR logical operator.

In the following example, two regular indexes and a composite index are created for an application:

title_index: the index on the title field. body_index: the index on the body field. union_index: the composite index on the title and body fields.

Content of a document in the application:

id:123456,title:Open,body:Search

The following code provides two search examples:

# If the two regular indexes and the OR logical operator are used, the document cannot be retrieved.
query=title_index:'OpenSearch' OR body_index:'OpenSearch'

# If the composite index is used, the document can be retrieved.
query=union_index:'OpenSearch'

Note:

  • The fields on which a composite index is created must be of the same type, which can be TEXT or SHORT_TEXT. You cannot create a composite index on fields of different types.

  • The fields on which the default index of the system is created must be the TEXT type.

Analyzer types

Text analyzers: You can use text analyzers to segment the text of the Chinese, English, general industry, IT, E-commerce, and education types to retrieve documents. You can also use text analyzers to perform exact searches by numeric or fixed-length value, fuzzy searches, and searches by range. Searches by range can be searched by location, time range, or numerical range.

Vector analyzers: You can use vector analyzers to retrieve documents based on multi-dimensional vectors in the general industry or retrieve general documents based on 256-dimensional vectors in the education industry.

Attribute fields

Usage notes: Attribute fields can be used in the filter, aggregate, sort, and distinct clauses to implement filtering, statistics, and sort features. Example: "filter=id>100000".