All Products
Search
Document Center

OpenSearch:How do I use indexes, attributes, and fields in OpenSearch?

Last Updated:Feb 09, 2023

Term comparison between OpenSearch and open source Elasticsearch

OpenSearch is a large-scale distributed search engine that is developed by Alibaba Cloud. Specific terms in OpenSearch and Elasticsearch are identical in names but differ in definitions and usage. The following two tables describe those terms.

Elasticsearch

Term

Description

Comparison with that in a relational database

index

The logical storage of logical data in Elasticsearch.

The name of the database.

field

In Elasticsearch, fields are created after data types are created. Data types are created after indexes are created.

The name of an attribute in a table.

attribute

The data type of a field, such as the STRING, INT, or DOUBLE type.

The data type of a field, such as the STRING, INT, or DOUBLE type.

OpenSearch

Term

Description

Comparison with that in a relational database

index

The data structure that is used to accelerate document retrieval. You can create multiple indexes.

The data structure that is used to presort one or more column values in a relational database. You can use indexes to find the data entries that meet the requirements without the need to scan the whole table in a database.

field

A component of a document. A field consists of a field name and a field value.

The name of an attribute in a table.

attribute

Attribute fields can be used in the filter, sort, aggregate, and distinct clauses of queries to implement features such as filtering and statistics. The definition and usage of the attribute described herein are specific to OpenSearch.

The name of an attribute in a table.

Definitions and usage of indexes, attributes, and fields in OpenSearch

Index: In OpenSearch, indexes are used to retrieve documents, and the retrieval process relies on the analysis of documents. Documents can be regarded as fields that are used for retrieval. Therefore, indexes are associated with analyzers and fields. An index can be associated with only one analyzer, whereas an analyzer can be associated with multiple indexes. An index can be associated with one or more fields. For example, a composite index is associated with multiple fields.

Attribute: The definition and usage of the attribute described herein are unique to OpenSearch. If you want to use the filter, sort, aggregate, or distinct clause for specific fields, these fields must be configured as attributed fields. An attribute is a mark of a field, which indicates that the field may be referenced in the preceding clauses.

Field: The usage of a field is simple. Each document that is retrieved by using indexes and attributes contains multiple fields. A document is similar to a data entry in a database. In addition, fields in OpenSearch are used to map the fields of data sources. Fields are defined in OpenSearch. If you want to import data from data sources to OpenSearch, you must map the fields of the data sources to the fields in OpenSearch. This ensures consistency between data types, field names, and field values.

Note: This topic helps you understand indexes, attributes, and fields. For more information, see Application schema and index schema.

Other usage of indexes and fields

Index:

Field: