All Products
Search
Document Center

Tablestore:Post-query filter

Last Updated:Apr 02, 2026

Post-query filter (Filter) applies an additional filtering pass to search index query results, allowing you to override the internal query optimizer and force specific conditions to execute in the final stage. When used properly, this feature can significantly improve query performance.

Note

To use the post-query filter feature, contact Tablestore technical support to enable this feature.

How it works

Post-query filter (Filter) uses a query syntax different from a standard query. It executes after the query stage and before the aggregate and GroupBy stages.

The primary purpose is to improve query performance by manually controlling the query flow. Moving high-hit-count query conditions from the query stage to the filter stage can significantly boost query performance.

  • Query stage: Supports all search index query types, including range query, term query, fuzzy query, and geo query, across all data types. This stage retrieves the initial dataset that matches the specified conditions from the index.

  • Filter stage: Applies secondary filtering to the query stage results. This stage supports only the Keyword, Long, and Double data types, and supports term query, range query, and exists query.

Comparison with other filtering methods

Differences from Elasticsearch post_filter

The key difference is where each filter takes effect in the execution pipeline:

  1. Tablestore Filter execution order: Query -> Filter -> Aggregate/TotalCount

  2. Elasticsearch post_filter execution order: Query -> Aggregate/TotalCount -> PostFilter

Differences from the filter in Tablestore BoolQuery

The filter clause in a BoolQuery functions similarly to the must clause and is a sub-feature of the query itself. It does not constitute a separate post-query filtering stage.

Limitations

  • Post-query filter must be used in combination with a search index query. Supported query types include TermQuery, TermsQuery, RangeQuery, ExistsQuery, and BoolQuery.

  • In a BoolQuery, only the mustQueries, mustNotQueries, and shouldQueries clauses are supported. The filterQueries clause is not supported.

  • Only Keyword, Long, and Double fields with the enableSortAndAgg property enabled support filtering.

  • Weight settings are not supported in post-query filters.

Usage

Post-query filter is currently supported through the Java SDK and Go SDK.