Skip to main content
  • Type: string
  • Default: ""(no filters)
  • Scope: search
The filters parameter lets you specify numeric, facet, and tag filters using an SQL-like syntax with support for boolean operators and parentheses.

Usage

  • All filterable attributes must be listed in attributesForFaceting, except for _tags, which is always available.
  • You can combine filters using AND, OR, and NOT, and group expressions with parentheses.
  • Use quotes for:
    • Attribute names or values with spaces.
    • Values that conflict with keywords (AND, OR, NOT).
    • Values that contain single (') or double (") quotes.

Filter types

  • Facet filters Syntax: facet:value
    Example: category:Book
    → Matches records where category is Book
    Facet names are case-sensitive, facet values are not.
  • Boolean filters Syntax: facet:true or facet:false
    Example: isEnabled:true
    → Matches records where isEnabled is true or "true"
  • Numeric comparisons Syntax: facet <operator> value
    Operators: <, <=, =, !=, >=, >
    Example: price > 12.99
  • Numeric ranges Syntax: facet:low TO high
    Example: price:5.99 TO 100
    → Includes both bounds.
  • Tag filters Syntax: _tags:value or value
    Example: published
    → Matches records where _tags is published.
    Tag matching is case-sensitive.
  • Array attributes A filter matches if it matches any element in the array. Example: genres:thriller matches genres: ["fiction", "thriller", "sci-fi"].
  • Nested attributes You can filter nested fields if they’re declared in attributesForFaceting. Example: authors.mainAuthor:"John Doe".

Examples

Current API clients

Apply filters on a search query

var response = await client.SearchSingleIndexAsync<Hit>(
  "ALGOLIA_INDEX_NAME",
  new SearchParams(
    new SearchParamsObject
    {
      Query = "query",
      Filters = "(category:Book OR category:Ebook) AND _tags:published",
    }
  )
);

Complex filters

var response = await client.SearchSingleIndexAsync<Hit>(
  "ALGOLIA_INDEX_NAME",
  new SearchParams(
    new SearchParamsObject
    {
      Query = "query",
      Filters =
        "available = 1 AND (category:Book OR NOT category:Ebook) AND _tags:published AND publication_date:1441745506 TO 1441755506 AND inStock > 0 AND author:\"John Doe\"",
    }
  )
);

Attributes with spaces

var response = await client.SearchSingleIndexAsync<Hit>(
  "ALGOLIA_INDEX_NAME",
  new SearchParams(
    new SearchParamsObject { Query = "query", Filters = "category:\"Books and Comics\"" }
  )
);

Attributes conflicting with keywords

var response = await client.SearchSingleIndexAsync<Hit>(
  "ALGOLIA_INDEX_NAME",
  new SearchParams(new SearchParamsObject { Query = "query", Filters = "keyword:\"OR\"" })
);

Attributes with single quotes

var response = await client.SearchSingleIndexAsync<Hit>(
  "ALGOLIA_INDEX_NAME",
  new SearchParams(
    new SearchParamsObject { Query = "query", Filters = "content:\"It's a wonderful day\"" }
  )
);

Attributes with double quotes

var response = await client.SearchSingleIndexAsync<Hit>(
  "ALGOLIA_INDEX_NAME",
  new SearchParams(
    new SearchParamsObject { Query = "query", Filters = "content:\"She said \"Hello World\"" }
  )
);

Apply filters on a search query

index.Search(new Query("query")
{
    Filters = "(category:Book OR category:Ebook) AND _tags:published"
});

Complex filters

string filters = "available = 1 AND (category:Book OR NOT category:Ebook) AND _tags:published AND publication_date:1441745506 TO 1441755506 AND inStock > 0 AND author:\"John Doe\"";

index.Search(new Query("query")
{
    Filters = filters
});

Attributes with spaces

index.Search(new Query("query")
{
    Filters = "category:'Books and Comics'"
});

Attributes conflicting with keywords

index.Search(new Query("query")
{
    Filters = "keyword:'OR'"
});

Attributes with single quotes

index.Search(new Query("query")
{
    Filters = "content:'It\\'s a wonderful day'"
});

Attributes with double quotes

index.Search(new Query("query")
{
    Filters = "content:'She said \"Hello World\"'"
});
I