Skip to main content

Module

Declarative filter builders for SDK queries.

Filter

Base class for declarative filter construction. This class defines the interface for building type-safe filters that can be used with LogStream queries and other SDK operations.

TextFilter

Builder for text-based filters. Supports operators: equals, not_equals, contains, one_of, not_in Examples
text("input").equals("hello")
text("status").contains("error")
text("name").one_of(["Alice", "Bob"])

contains

def contains(self, value: str) -> LogRecordsTextFilter
Filter for text that contains a substring. Arguments
  • value: The substring to search for.

equals

def equals(self, value: str) -> LogRecordsTextFilter
Filter for exact text match. Arguments
  • value: The text value to match.

not_equals

def not_equals(self, value: str) -> LogRecordsTextFilter
Filter for text that does not match. Arguments
  • value: The text value to exclude.

not_in

def not_in(self, values: list[str]) -> LogRecordsTextFilter
Filter for text that does not match any value in a list. Arguments
  • values: List of text values to exclude.

one_of

def one_of(self, values: list[str]) -> LogRecordsTextFilter
Filter for text that matches any value in a list. Arguments
  • values: List of text values to match.

NumberFilter

Builder for number-based filters. Supports operators: equals, not_equals, greater_than, greater_than_or_equal, less_than, less_than_or_equal, between Examples
number("score").greater_than(0.8)
number("count").between(10, 100)
number("rating").equals(5)

between

def between(self,
            min_value: int | float,
            max_value: int | float) -> LogRecordsNumberFilter
Filter for numbers within a range (inclusive). Arguments
  • min_value: The minimum value (inclusive).
  • max_value: The maximum value (inclusive).

equals

def equals(self, value: int | float) -> LogRecordsNumberFilter
Filter for exact number match. Arguments
  • value: The number to match.

greater_than

def greater_than(self, value: int | float) -> LogRecordsNumberFilter
Filter for numbers greater than a value. Arguments
  • value: The threshold value (exclusive).

greater_than_or_equal

def greater_than_or_equal(self, value: int | float) -> LogRecordsNumberFilter
Filter for numbers greater than or equal to a value. Arguments
  • value: The threshold value (inclusive).

less_than

def less_than(self, value: int | float) -> LogRecordsNumberFilter
Filter for numbers less than a value. Arguments
  • value: The threshold value (exclusive).

less_than_or_equal

def less_than_or_equal(self, value: int | float) -> LogRecordsNumberFilter
Filter for numbers less than or equal to a value. Arguments
  • value: The threshold value (inclusive).

not_equals

def not_equals(self, value: int | float) -> LogRecordsNumberFilter
Filter for numbers that don’t match. Arguments
  • value: The number to exclude.

DateFilter

Builder for date-based filters. Supports operators: equals, not_equals, before, after, on_or_before, on_or_after Examples
date("created_at").after("2024-01-01")
date("updated_at").before(datetime.now())
date("published_at").on_or_after("2024-01-01")

after

def after(self, value: str | datetime.datetime) -> LogRecordsDateFilter
Filter for dates after a value (exclusive). Arguments
  • value: The threshold date (string or datetime).

before

def before(self, value: str | datetime.datetime) -> LogRecordsDateFilter
Filter for dates before a value (exclusive). Arguments
  • value: The threshold date (string or datetime).

equals

def equals(self, value: str | datetime.datetime) -> LogRecordsDateFilter
Filter for exact date match. Arguments
  • value: The date to match (string or datetime).

not_equals

def not_equals(self, value: str | datetime.datetime) -> LogRecordsDateFilter
Filter for dates that don’t match. Arguments
  • value: The date to exclude (string or datetime).

on_or_after

def on_or_after(self, value: str | datetime.datetime) -> LogRecordsDateFilter
Filter for dates on or after a value (inclusive). Arguments
  • value: The threshold date (string or datetime).

on_or_before

def on_or_before(self, value: str | datetime.datetime) -> LogRecordsDateFilter
Filter for dates on or before a value (inclusive). Arguments
  • value: The threshold date (string or datetime).

BooleanFilter

Builder for boolean-based filters. Boolean filters are simple equality checks - there are no operators, just matching against true or false values. Examples
boolean("is_active").is_true()
boolean("has_error").is_false()
boolean("enabled").equals(True)

equals

def equals(self, value: bool) -> LogRecordsBooleanFilter
Filter for exact boolean match. Arguments
  • value: The boolean value to match (True or False).

is_false

def is_false(self) -> LogRecordsBooleanFilter
Filter for boolean columns that are False.

Returns

LogRecordsBooleanFilter: A configured boolean filter for False.

is_true

def is_true(self) -> LogRecordsBooleanFilter
Filter for boolean columns that are True.

Returns

LogRecordsBooleanFilter: A configured boolean filter for True.

boolean

def boolean(column_id: str) -> BooleanFilter
Create a boolean filter builder. Arguments
  • column_id: The ID of the column to filter on.

date

def date(column_id: str) -> DateFilter
Create a date filter builder. Arguments
  • column_id: The ID of the column to filter on.

number

def number(column_id: str) -> NumberFilter
Create a number filter builder. Arguments
  • column_id: The ID of the column to filter on.

text

def text(column_id: str, case_sensitive: bool=True) -> TextFilter
Create a text filter builder. Arguments
  • column_id: The ID of the column to filter on.
  • case_sensitive: Whether the filter should be case-sensitive. Default is True.