Data query

更新时间:
复制 MD 格式

Search indexes in Tablestore SDK for Go support basic queries, Boolean query, sorting and paging, aggregation, full-text search, and k-nearest neighbor (KNN) vector query.

Basic queries

The following table lists the basic query types supported by search indexes.

Query type

Description

Match all query

Matches all rows in a table. You can use this query to get the total row count or return random rows.

Term query

Retrieves rows that exactly match a specified column value, similar to string matching.

Terms query

Retrieves rows whose column value matches at least one of the specified keywords, equivalent to the IN operator in SQL.

Prefix query

Retrieves rows whose column value contains a specified prefix.

Wildcard query

Retrieves rows whose column value matches a string that contains wildcard characters.

Range query

Retrieves rows whose column value falls within a specified range.

Exists query

Also called a NULL query or NULL-value query. Determines whether a specific column exists in a row, which is useful for sparse data.

Collapse (distinct)

Collapses the result set based on a specific column so that only one row per distinct value is returned, ensuring diversity in the results.

Geo query

Geo queries include the following types:

  • Geo-distance query: Retrieves rows in which the value of a geo-point field falls within a circular area defined by a central point and a radius.

  • Geo-bounding box query: Retrieves rows in which the value of a geo-point field falls within a specified rectangular area.

  • Geo-polygon query: Retrieves rows in which the value of a geo-point field falls within a specified polygon area.

Nested query

Queries the child rows of nested fields.

Boolean query

A Boolean query combines multiple subqueries and returns rows that match the specified conditions. For more information, see Boolean query.

Sorting and paging

You can predefine a sort method when you create a search index or specify one at query time. For large result sets, paginate by configuring the limit and offset parameters or by using tokens. For more information, see Sorting and paging.

Aggregation

Aggregation operations return statistics such as minimum, maximum, sum, average, count, distinct count, and percentiles. You can also group results by field value, range, geographical location, filter, histogram, or date histogram, perform nested queries, and query rows from aggregation results within each group. Multiple aggregations can be chained for complex analytics. For more information, see Aggregation.

Full-text search

Full-text search finds rows that contain specified query strings. You can configure highlight parameters to mark matched terms in the returned results. For more information, see Full-text search.

KNN vector query

KNN vector query performs approximate nearest neighbor searches to find the most similar items to a given vector in large-scale datasets. For more information, see KNN vector query.