All Products
Search
Document Center

Tablestore:Post-query filter

Last Updated:Nov 28, 2025

The post-query filter (Filter) is a feature for Tablestore Search Index that applies an additional filter to query results. This lets you manually control the internal query optimizer and force specific query conditions to run in the final stage. Using this feature correctly can significantly improve query performance.

Note

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

Function introduction

The post-query filter (Filter) uses a query syntax that is different from a standard query. It runs after the query stage and before the aggregate and GroupBy stages.

The main purpose is to improve query performance by manually controlling the query flow. Moving query conditions with many hits from the query stage to the filter stage can significantly improve query performance.

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

  • Filter stage: Filters the results from the query stage. This stage supports only the Keyword, Long, and Double data types. Supported query types include term query, range query, and exists query.

Comparison with other filtering methods

Differences from Elasticsearch post_filter

The main difference between the two is their scope of effect:

  1. Execution order of Filter in Tablestore: Query → Filter → Aggregate/TotalCount

  2. Execution order of post_filter in Elasticsearch: Query → Aggregate/TotalCount → PostFilter

Differences from the filter in Tablestore BoolQuery

The filter in a BoolQuery is similar to the must clause and is a component of the query itself.

Limits

  • The post-query filter must be used with a search index query. Supported query types are TermQuery, TermsQuery, RangeQuery, ExistsQuery, and BoolQuery.

  • For a BoolQuery, the `mustQueries`, `mustNotQueries`, and `shouldQueries` clauses are supported, but the `filterQueries` clause is not.

  • Filtering is supported only for Keyword, Long, and Double fields for which the `enableSortAndAgg` property is enabled.

  • Post-query filters do not support setting weights.

Usage

You can use the post-query filter with the Java SDK and Go SDK.