Skip to main content
Faceting adds overhead at both indexing and search time. Every filterable attribute requires Meilisearch to build internal data structures, and every facet distribution request computes counts across all matching documents. This page covers the main levers you can use to minimize that cost.

Use granular filterable attributes

By default, adding an attribute to filterableAttributes enables equality filters, comparison filters, and facet search. Most attributes only need a subset of these features. Use granular filterable attributes to enable only what you need.

Choose the right features per attribute

Attribute typeExampleRecommended features
Categories, tags, brandsgenre, color, brandfilter.equality: true, facetSearch: true
Numeric rangesprice, rating, yearfilter.equality: true, filter.comparison: true, facetSearch: false
Boolean flagsin_stock, is_featuredfilter.equality: true, filter.comparison: false, facetSearch: false
Internal IDs used only for filteringtenant_id, user_idfilter.equality: true, filter.comparison: false, facetSearch: false
Apply this with a wildcard default and specific overrides:
{
  "filterableAttributes": [
    {
      "attributePatterns": ["*"],
      "features": {
        "facetSearch": false,
        "filter": {
          "equality": true,
          "comparison": false
        }
      }
    },
    {
      "attributePatterns": ["genre", "color", "brand"],
      "features": {
        "facetSearch": true,
        "filter": {
          "equality": true,
          "comparison": false
        }
      }
    },
    {
      "attributePatterns": ["price", "rating"],
      "features": {
        "facetSearch": false,
        "filter": {
          "equality": true,
          "comparison": true
        }
      }
    }
  ]
}
This configuration:
  • Sets a restrictive default for all attributes (equality only, no facet search)
  • Enables facet search only on categorical attributes that appear in your sidebar
  • Enables comparison operators only on numeric attributes that need range filtering
The fewer features enabled, the less work Meilisearch does during indexing. The improvement scales with the number of filterable attributes and the size of your dataset.

Lower maxValuesPerFacet

The maxValuesPerFacet setting (default: 100) controls how many distinct values Meilisearch returns per attribute in the facetDistribution response. If your UI only displays 10 or 20 facet values per category, computing counts for 100 is unnecessary work.
curl \
  -X PATCH 'MEILISEARCH_URL/indexes/products/settings/faceting' \
  -H 'Content-Type: application/json' \
  -H 'Authorization: Bearer MEILISEARCH_KEY' \
  --data-binary '{
    "maxValuesPerFacet": 20
  }'
Set this to the number of values you actually display. If your sidebar shows the top 10 brands, set maxValuesPerFacet to 10 or 15 (a small margin lets you implement “Show more” without a separate request). For attributes with high cardinality (cities, tags, SKU variants), this setting has the largest impact on search latency. Facet search lets users type inside a facet group to find specific values (e.g., searching for “Nik” to find “Nike” in the brands facet). If you do not use this feature, disabling it reduces the data structures Meilisearch builds during indexing.

Disable globally for an index

curl \
  -X PUT 'MEILISEARCH_URL/indexes/products/settings/facet-search' \
  -H 'Content-Type: application/json' \
  -H 'Authorization: Bearer MEILISEARCH_KEY' \
  --data-binary 'false'
This disables the /indexes/{index_uid}/facet-search endpoint entirely. Documents are still indexed for regular facet distribution, but Meilisearch skips the additional processing needed for facet search.

Disable per attribute

If you need facet search on some attributes but not others, use granular filterable attributes instead of the global toggle:
{
  "filterableAttributes": [
    {
      "attributePatterns": ["brand"],
      "features": {
        "facetSearch": true,
        "filter": { "equality": true, "comparison": false }
      }
    },
    {
      "attributePatterns": ["color", "size", "in_stock"],
      "features": {
        "facetSearch": false,
        "filter": { "equality": true, "comparison": false }
      }
    }
  ]
}
This enables facet search only on brand (which may have hundreds of values) and disables it on color, size, and in_stock (which have a small, known set of values).

Request only the facets you need

At search time, only include the attributes you need in the facets parameter. Each attribute listed in facets requires Meilisearch to compute a count for every distinct value.
{
  "q": "running shoes",
  "facets": ["brand", "color"]
}
Avoid requesting facets you do not display. If a page only shows brand and color filters, do not include size, price, or rating in the facets array.

Summary

OptimizationWhen to useImpact
Granular filterable attributesAlways, when you have more than a few filterable attributesReduces indexing time and memory
Lower maxValuesPerFacetWhen attributes have many unique valuesReduces search latency
Disable facet search (global)When you never use the facet search endpointReduces indexing time
Disable facet search (per attribute)When only some attributes need facet searchReduces indexing time
Request fewer facets at search timeAlwaysReduces search latency

Next steps

Configure granular filters

Full guide to granular filterable attributes.

Build disjunctive facets

Implement faceted navigation where selecting a value does not collapse counts in the same group.

Debug search performance

Identify which part of the search pipeline is slow.