Advanced filters

More filters options and customisability

The python interface is a quick way that simplifies the way filters are constructured. The following explores how to create a more indepth filter with a lot of customisability.

How to form a filter?

Filters at Relevance AI are defined as Python dictionaries with four main keys:

  • field (i.e. the data filed in the document you want to filter on)
  • condition (i.e. operators such as greater than or equal)
  • filter_type (i.e. the type of filter you want to apply - whether it be date/numeric/text etc.)
  • condition_value (dependent on the filter type but decides what value to filter on)
filter = [
    {
        "field": "description",
        "filter_type": "contains",
        "condition": "==",
        "condition_value": "Apple"
    }
]

Filtering operators

Relevance AI covers all common operators:

  • "==" (a == b, a equals b)
  • "!=" (a != b, a not equals b)
  • ">=" (a >= b, a greater that or equals b)
  • ">" (a > b, a greater than b)
  • "<" (a < b, a smaller than b)
  • "<=" (a <= b, a smaller than or equals b)

Filter types

Supported filter types at Relevance AI are listed below.

  • contains
  • exact_match
  • word_match
  • categories
  • exists
  • date
  • numeric
  • ids
  • support for mixing together multiple filters such as in OR situations

We will explain each filter type followed by a sample code snippet in the next pages.