- Reference >
- Database Commands >
- Query Plan Cache Commands >
- planCacheClearFilters
planCacheClearFilters¶
On this page
Definition¶
-
planCacheClearFilters¶ Removes index filters on a collection. Although index filters only exist for the duration of the server process and do not persist after shutdown, you can also clear existing index filters with the
planCacheClearFilterscommand.Specify the query shape to remove a specific index filter. Omit the query shape to clear all index filters on a collection.
Syntax¶
The command has the following syntax:
Command Fields¶
The command has the following fields:
| Field | Type | Description |
|---|---|---|
planCacheClearFilters |
string | The name of the collection to remove the index filters from. |
query |
document | Optional. The query predicate for the index filter to remove. If omitted, the command clears all index filters from the collection. The values in the
|
sort |
document | Optional. The sort for the index filter to remove, if any. |
projection |
document | Optional. The projection for the index filter to remove, if any. |
collation |
document | Specifies the collation to use for the operation. Collation allows users to specify language-specific rules for string comparison, such as rules for lettercase and accent marks. The collation option has the following syntax: When specifying collation, the If the collation is unspecified but the collection has a
default collation (see If no collation is specified for the collection or for the operations, MongoDB uses the simple binary comparison used in prior versions for string comparisons. You cannot specify multiple collations for an operation. For example, you cannot specify different collations per field, or if performing a find with a sort, you cannot use one collation for the find and another for the sort. Starting in MongoDB 6.0, an index filter uses the collation previously set using the |
comment |
any | Optional. A user-provided comment to attach to this command. Once set, this comment appears alongside records of this command in the following locations:
A comment can be any valid BSON type (string, integer, object, array, etc). New in version 4.4. |
Required Access¶
A user must have access that includes the
planCacheIndexFilter action.
Examples¶
Clear Specific Index Filter on Collection¶
The orders collection contains the following index filters:
Note
Starting in MongoDB 6.0, an index filter uses the collation previously set using the planCacheSetFilter
command.
The following command removes the second index filter only:
Because the values in the query predicate are insignificant in
determining the query shape, the following command would also
remove the second index filter:
Clear all Index Filters on a Collection¶
The following example clears all index filters on the orders
collection:
Clear Index Filter Containing a Query and a Collation¶
The following example clears the index filter containing the query on
Movie and the collation en_US for the orders collection:
See also