Skip to main content
  • Type: list<string>
  • Default: []
  • Scope: search
Use the filters parameter instead. It supports boolean combinations of multiple filters, and unifies numericFilters, tagFilters, facetFilters into a single syntax.

Usage

To use an attribute as facet filter, it must be included in the attributesForFaceting setting.

Single facet filter

Specify a filter using the "facet:value" syntax. For example, "genre:comedy" returns only records where the genre attribute is comedy.

Negative filter

Prefix the value with a minus sign to exclude matches: "facet:-value". For example, "genre:-comedy" excludes records where genre is comedy.

Combining filters with AND and OR

Use a flat array for AND conditions: ["category:Book", "author:John Doe"] returns records where category is Book and author is John Doe. Use nested arrays for OR conditions:
[["genre:comedy", "genre:drama"]] returns records where genre is either comedy or drama.
You can combine AND with OR: [["category:Book", "category:Movie"], "author:John Doe"] means (category:Book OR category:Movie) AND author:John Doe.
You can’t group AND conditions inside an OR group. (A AND B) OR C is invalid.

Escape minus signs

If a facet value starts with -, escape it with a backslash: category:\-Movie. This also applies to negative numbers: "count:\-12" matches string or numeric values equal to -12. To filter only numeric values, use numericFilters.

Examples

Current API clients

Single facet filter

var response = await client.SearchSingleIndexAsync<Hit>(
  "ALGOLIA_INDEX_NAME",
  new SearchParams(
    new SearchParamsObject
    {
      Query = "query",
      FacetFilters = new FacetFilters(
        new List<FacetFilters> { new FacetFilters("category:Book") }
      ),
    }
  )
);

Two filters with AND

var response = await client.SearchSingleIndexAsync<Hit>(
  "ALGOLIA_INDEX_NAME",
  new SearchParams(
    new SearchParamsObject
    {
      Query = "query",
      FacetFilters = new FacetFilters(
        new List<FacetFilters>
        {
          new FacetFilters("category:Book"),
          new FacetFilters("author:John Doe"),
        }
      ),
    }
  )
);

Two filters with OR

var response = await client.SearchSingleIndexAsync<Hit>(
  "ALGOLIA_INDEX_NAME",
  new SearchParams(
    new SearchParamsObject
    {
      Query = "query",
      FacetFilters = new FacetFilters(
        new List<FacetFilters>
        {
          new FacetFilters(
            new List<FacetFilters>
            {
              new FacetFilters("category:Book"),
              new FacetFilters("author:John Doe"),
            }
          ),
        }
      ),
    }
  )
);

Multiple filters with AND and OR

var response = await client.SearchSingleIndexAsync<Hit>(
  "ALGOLIA_INDEX_NAME",
  new SearchParams(
    new SearchParamsObject
    {
      Query = "query",
      FacetFilters = new FacetFilters(
        new List<FacetFilters>
        {
          new FacetFilters(
            new List<FacetFilters>
            {
              new FacetFilters("category:Book"),
              new FacetFilters("author:John Doe"),
            }
          ),
        }
      ),
    }
  )
);

Single facet filter

index.Search(new Query("query")
{
    FacetFilters = new List> { new List { "category:Book" } } };
});

Two filters with AND

index.Search(new Query("query")
{
  FacetFilters = new List>
  {
    new List { "category:Book" },
    new List { "author:John Doe" },
  }
});

Two filters with OR

index.Search(new Query("query")
{
  FacetFilters = new List>
  {
    new List { "category:Book", "category:Movie" },
  }
});

Multiple filters with AND and OR

index.Search(new Query("query")
{
  FacetFilters = new List>
  {
    new List { "category:Book", "category:Movie" },
    new List { "author:John Doe" }
  }
});
I