Skip to main content
  • Type: list<string>
  • Default: []
  • Scope: search
Optional filters use the same syntax as facetFilters, but they behave differently:
They don’t exclude records. Instead, they influence the record’s ranking.
Use them to promote or demote results without filtering them out. For example:
  • To promote books by John Doe: ["category:Book", "author:John Doe"]
  • To demote items from the Books category: ["category:-Books"]

Usage

  • Optional filters only have an effect if the Filters ranking criterion is present in your ranking formula (default behavior).
  • Optional filters aren’t compatible with virtual replicas and may produce incorrect results.
  • They’re applied after any sorting criteria (sorting by attribute)
  • Numeric comparisons aren’t supported.
  • If the Filters ranking criterion is applied before custom ranking (default), the optional filters take precedence over the custom ranking in the tie-breaking algorithm.

Escape minus signs

If a facet value starts with - and is not a negative filter, escape it: category:\-movie.

Example

Current API clients

var query = new Query()
{
  SearchQuery = "query",
  OptionalFilters = new List>
  {
    new List { "category:Book", "author:John Doe" }
  }
};
var query = new Query()
{
  SearchQuery = "query",
  OptionalFilters = new List>
  {
    new List { "category:Book", "author:John Doe" }
  }
};
I