This topic describes the operations, fields, queries, and billing methods of search index.


You can use the following SDKs to implement search index.

API operations

Action Operation Description
Create CreateSearchIndex Creates a search index.
Describe DescribeSearchIndex Queries detailed information of a search index.
List ListSearchIndex Queries the list of search indexes.
Delete DeleteSearchIndex Deletes a specified search index.
Search Search Searches for required data.


The value of a search index field in Tablestore is the value of the field of the same name in the corresponding table. The types of these fields must match each other, as described in the following table.

Field type in the search index Field type in the table Description
Long Integer 64-bit long integers.
Double Double 64-bit long floating-point numbers.
Boolean Boolean Boolean values.
Keyword String Character strings that cannot be tokenized.
Text String

Character strings or text that can be tokenized. For more information, see Tokenization.

Geopoint String Geographical coordinates in latitude, longitude format. Example: 35.8,-45.91.
Nested String Nested type fields. Example: [{"a": 1}, {"a": 3}].
Notice The types in this table must map each other. Otherwise, Tablestore discards the data as dirty data. Make sure that fields of the Geopoint and Nested types comply with the formats described in the preceding table. If the formats do not match, Tablestore discards the data as dirty data. As a result, the data may be available in the table but unavailable in the search index.

Aside from the type attribute, search index fields also have additional attributes.

Attribute Type Option Description
Index Boolean Specifies whether to create an index for a column.
  • True indicates that Tablestore creates an inverted index or spatial index for the column.
  • False indicates that Tablestore does not create an index for the column.
  • If the column does not have any indexes, you cannot query by the column.
EnableSortAndAgg Boolean Specifies whether to enable sorting and aggregation.
  • True indicates that data can be sorted by using the column.
  • False indicates that data cannot be sorted by using the column.
Store Boolean Specifies whether to store original values in the index. True indicates that Tablestore stores original values in the column to the index. Therefore, Tablestore reads values of the column directly from the index, rather than from the base table. This optimizes search performance.
IsArray Boolean Specifies whether the column is an array.
  • True indicates that the column is an array. Data written to the column must be a JSON array. Example: ["a","b","c"].
  • You do not need to explicitly specify this parameter for Nested columns because they are arrays.
  • Array type data can be used in all queries because arrays do not affect queries.
The following table describes the attributes that each field type supports.
Type Index EnableSortAndAgg Store Array
Long Supported Supported Supported Supported
Double Supported Supported Supported Supported
Boolean Supported Supported Supported Supported
Keyword Supported Supported Supported Supported
Text Supported Not supported Supported Supported
Geopoint Supported Supported Supported Supported
Nested Required for child fields. Required for child fields. Required for child fields. Nested fields are arrays.

Query parameters and types

You must specify SearchRequest in a query. The following table describes parameters that are included in SearchRequest.
Parameter Type Description
offset Integer Specifies the position from which the current query starts.
limit Integer Specifies the maximum number of items that the current query returns.
getTotalCount Boolean Specifies whether to return the total number of matched rows. This parameter is set to false by default. A value of true may affect the query performance.
Sort Sort Specifies the field and method for sorting.
collapse Collapse Specifies the name of the field that you want to collapse in the query result.
query Query Specifies the type of the current query. The following table lists the query types.
Name Query Description
Query all rows MatchAllQuery You can use MatchAllQuery to query the total number of rows.
Query by tokenized data MatchQuery You can use MatchQuery to tokenize the query data, and query the tokenized data. The logical operator OR applies to tokens.
Query by phrases MatchPhraseQuery This query is similar to MatchQuery. The matched tokens must be adjacent to each other in the query data.
Query by exact match TermQuery You can use TermQuery to match exact strings. Tablestore uses exact matches to query data in a table, and does not tokenize the query data.
Query by multiple terms TermsQuery This query is similar to TermQuery. You can use TermsQuery to match multiple terms, which is similar to the SQL IN operator.
Query by prefix PrefixQuery You can use PrefixQuery to query data in a table by matching a specified prefix.
Query by range RangeQuery You can use RangeQuery to query data within a specified range in a table.
Query by wildcards WildcardQuery You can use WildcardQuery to query data based on strings that contain one or more wildcards. This query is similar to the SQL LIKE operator.
Query by a combination of filtering conditions BoolQuery You can use BoolQuery to combine multiple filtering conditions by using logical operators such as AND, OR, and NOT.
Query data within a rectangular geographical area GeoBoundingBoxQuery You can use GeoBoundingBoxQuery to specify a rectangular geographical area as a filtering condition in a query. Tablestore returns the rows where the value of a field falls within the rectangular geographical area.
Query data within a circular geographical area GeoDistanceQuery You can use GeoDistanceQuery to specify a circular geographical area consisting of a central point and radius as a filtering condition in a query. Tablestore returns the rows where the value of a field falls within the circular geographical area.
Query data within a polygonal geographical area GeoPolygonQuery You can use GeoPolygonQuery to specify a polygonal geographical area as a filtering condition in a query. Tablestore returns the rows where the value of a field falls within the polygonal geographical area.


For more information, see Billing items and pricing.