Resources

Renesas IoT Sandbox Documentation

Filter Library

Provides an interface for creating filters to be passed as parameters to Analytics and GlobalAnalytics functions.

There are five different Filter types that are created with Filter Constructors:

  • NumericFilter
  • StringFilter
  • DateFilter
  • BooleanFilter
  • GeoFilter

These filters can then be passed as parameters to the relevant Analytics and GlobalAnalytics functions directly, or after application of Filter Operators. For each type of filter, if an operation condition is not specified, they are treated as key existence filters, specific to that type of tag data type. In addition, multiple filters can be combined through the '&' operator to further constrain the Analytics queries.


Below is a table of the available Filter Operators:


All Filter types:



equal_to
not_equal_to
& (logical AND operation)

Specific to NumericFilter and DateFilter:




greater_than
greater_than_or_equal
less_than
less_than_or_equal

Specific to StringFilter:



contains
starts_with
ends_with

Specific to GeoFilter within




Import


To use this library and its functions, you must use the import line at the beginning of your Base Python code.

import Filter


Filter Constructors


Filter.numeric_tag

Usage: Filter.numeric_tag(name)

Represents a tag with numeric values.

  • Credit cost: 0
  • Parameters:
    • name: str|unicode Name of tag, including stream name (eg. "raw.score")
  • Returns: NumericFilter



Filter.string_tag

Usage: Filter.string_tag(name)

Represents a tag with string values.

  • Credit cost: 0
  • Parameters:
    • name: str|unicode Name of tag, including stream name (eg. "raw.city")
  • Returns: StringFilter



Filter.date_tag

Usage: Filter.date_tag(name)

Represents a tag with date value.

  • Credit cost: 0
  • Parameters:
    • name: str|unicode Name of tag, including stream name (eg. "raw.birthday")
  • Returns: DateFilter



Filter.boolean_tag

Usage: Filter.boolean_tag(name)

Represents a tag with a boolean value.

  • Credit cost: 0
  • Parameters:
    • name: str|unicode Name of tag, including stream name (eg. "raw.allowed_to_do_that")
  • Returns: BooleanFilter



Filter.geo_tag

Usage: Filter.geo_tag(name)

Represents a tag of type geopoint.

  • Credit cost: 0
  • Parameters:
    • name: str|unicode Name of tag, including stream name (eg. "raw.location")
  • Returns: GeoFilter



Filter Operators


Filter.equal_to

Usage: filter.equal_to(value)

Specifies that a tag (or boolean expression of tags) is equal to another value.

  • Credit cost: 0
  • Parameters:
    • value: Value, must be same type as Filter instance. e.g. (DateTime for DateFilters, True|False for BooleanFilter)
  • Returns: BooleanFilter



Filter.not_equal_to

Usage: filter.not_equal_to(value)

Opposite of Filter.equal_to

  • Credit cost: 0
  • Parameters:
    • value: Value must be same type as Filter instance. e.g. (DateTime for DateFilters, True|False for BooleanFilter)
  • Returns: BooleanFilter



Filter & (Logical AND Operation)

Usage: filter & filter

Represents a boolean And operation

  • Credit cost: 0
  • Parameters:
    • filter: Must be a BooleanFilter
  • Returns: BooleanFilter



NumericFilter.greater_than

Usage: filter.greater_than(value)

Asserts that a numeric tag is greater than the given value.

  • Credit cost: 0
  • Parameters:
    • value: Must be a Number type
  • Returns: BooleanFilter



NumericFilter.greater_than_or_equal

Usage: filter.greater_than_or_equal(value)

Asserts that a numeric tag is greater than or equal to the given value.

  • Credit cost: 0
  • Parameters:
    • value: Must be a Number type
  • Returns: BooleanFilter



NumericFilter.less_than

Usage: filter.less_than(value)

Asserts that a numeric tag is less than the given value.

  • Credit cost: 0
  • Parameters:
    • value: Must be a Number type
  • Returns: BooleanFilter



NumericFilter.less_than_or_equal

Usage: filter.less_than_or_equal(value)

Asserts that a numeric tag is less than or equal to the given value.

  • Credit cost: 0
  • Parameters:
    • value: Must be a Number type
  • Returns: BooleanFilter



GeoFilter.within

Usage: filter.within(radius,location)

Asserts that a geopoint tag is within the radius of the given location.

  • Credit cost: 0
  • Parameters:
    • radius: Must be a Number type. Units is in meters.
    • location: Must be a ISO geopoint string of type 'latitude longitude altitude' or an array of numeric values [latitude, longitude, altitude]
  • Returns: BooleanFilter



StringFilter.contains

Usage: filter.contains(value)

Asserts that a string tag contains the given value.

  • Credit cost: 0
  • Parameters:
    • value: Must be a String type
  • Returns: BooleanFilter



StringFilter.starts_with

Usage: filter.starts_with(value)

Asserts that a string tag starts with the given value.

  • Credit cost: 0
  • Parameters:
    • value: Must be a String type
  • Returns: BooleanFilter



StringFilter.ends_with

Usage: filter.ends_with(value)

Asserts that a string tag ends with the given value.

  • Credit cost: 0
  • Parameters:
    • value: Must be a String type
  • Returns: BooleanFilter



Sample Code


import Filter

# asserts 'bpm' == 120
Filter.numeric_tag('raw.bpm').equal_to(120)

# asserts 'name' != 'Joe'
Filter.string_tag('raw.name').not_equal_to('Joe')

# asserts 'age' > 20 and 'bpm' > 80
age_filter = Filter.numeric_tag('age').greater_than(20)
bpm_filter = Filter.numeric_tag('bpm').greater_than(80)
comb_filter = age_filter & bpm_filter

Getting Started
User Roles & Permissions
Streams, Tags, & Data Types
Dashboard Widgets
API
Workflow Studio
Workflow Libraries
Metering
Special Characters
Third Party Integration
Mobile
API Explorer

Filter Library

Provides an interface for creating filters to be passed as parameters to Analytics and GlobalAnalytics functions.

There are five different Filter types that are created with Filter Constructors:

  • NumericFilter
  • StringFilter
  • DateFilter
  • BooleanFilter
  • GeoFilter

These filters can then be passed as parameters to the relevant Analytics and GlobalAnalytics functions directly, or after application of Filter Operators. For each type of filter, if an operation condition is not specified, they are treated as key existence filters, specific to that type of tag data type. In addition, multiple filters can be combined through the '&' operator to further constrain the Analytics queries.


Below is a table of the available Filter Operators:


All Filter types:



equal_to
not_equal_to
& (logical AND operation)

Specific to NumericFilter and DateFilter:




greater_than
greater_than_or_equal
less_than
less_than_or_equal

Specific to StringFilter:



contains
starts_with
ends_with

Specific to GeoFilter within




Import


To use this library and its functions, you must use the import line at the beginning of your Base Python code.

import Filter


Filter Constructors


Filter.numeric_tag

Usage: Filter.numeric_tag(name)

Represents a tag with numeric values.

  • Credit cost: 0
  • Parameters:
    • name: str|unicode Name of tag, including stream name (eg. "raw.score")
  • Returns: NumericFilter



Filter.string_tag

Usage: Filter.string_tag(name)

Represents a tag with string values.

  • Credit cost: 0
  • Parameters:
    • name: str|unicode Name of tag, including stream name (eg. "raw.city")
  • Returns: StringFilter



Filter.date_tag

Usage: Filter.date_tag(name)

Represents a tag with date value.

  • Credit cost: 0
  • Parameters:
    • name: str|unicode Name of tag, including stream name (eg. "raw.birthday")
  • Returns: DateFilter



Filter.boolean_tag

Usage: Filter.boolean_tag(name)

Represents a tag with a boolean value.

  • Credit cost: 0
  • Parameters:
    • name: str|unicode Name of tag, including stream name (eg. "raw.allowed_to_do_that")
  • Returns: BooleanFilter



Filter.geo_tag

Usage: Filter.geo_tag(name)

Represents a tag of type geopoint.

  • Credit cost: 0
  • Parameters:
    • name: str|unicode Name of tag, including stream name (eg. "raw.location")
  • Returns: GeoFilter



Filter Operators


Filter.equal_to

Usage: filter.equal_to(value)

Specifies that a tag (or boolean expression of tags) is equal to another value.

  • Credit cost: 0
  • Parameters:
    • value: Value, must be same type as Filter instance. e.g. (DateTime for DateFilters, True|False for BooleanFilter)
  • Returns: BooleanFilter



Filter.not_equal_to

Usage: filter.not_equal_to(value)

Opposite of Filter.equal_to

  • Credit cost: 0
  • Parameters:
    • value: Value must be same type as Filter instance. e.g. (DateTime for DateFilters, True|False for BooleanFilter)
  • Returns: BooleanFilter



Filter & (Logical AND Operation)

Usage: filter & filter

Represents a boolean And operation

  • Credit cost: 0
  • Parameters:
    • filter: Must be a BooleanFilter
  • Returns: BooleanFilter



NumericFilter.greater_than

Usage: filter.greater_than(value)

Asserts that a numeric tag is greater than the given value.

  • Credit cost: 0
  • Parameters:
    • value: Must be a Number type
  • Returns: BooleanFilter



NumericFilter.greater_than_or_equal

Usage: filter.greater_than_or_equal(value)

Asserts that a numeric tag is greater than or equal to the given value.

  • Credit cost: 0
  • Parameters:
    • value: Must be a Number type
  • Returns: BooleanFilter



NumericFilter.less_than

Usage: filter.less_than(value)

Asserts that a numeric tag is less than the given value.

  • Credit cost: 0
  • Parameters:
    • value: Must be a Number type
  • Returns: BooleanFilter



NumericFilter.less_than_or_equal

Usage: filter.less_than_or_equal(value)

Asserts that a numeric tag is less than or equal to the given value.

  • Credit cost: 0
  • Parameters:
    • value: Must be a Number type
  • Returns: BooleanFilter



GeoFilter.within

Usage: filter.within(radius,location)

Asserts that a geopoint tag is within the radius of the given location.

  • Credit cost: 0
  • Parameters:
    • radius: Must be a Number type. Units is in meters.
    • location: Must be a ISO geopoint string of type 'latitude longitude altitude' or an array of numeric values [latitude, longitude, altitude]
  • Returns: BooleanFilter



StringFilter.contains

Usage: filter.contains(value)

Asserts that a string tag contains the given value.

  • Credit cost: 0
  • Parameters:
    • value: Must be a String type
  • Returns: BooleanFilter



StringFilter.starts_with

Usage: filter.starts_with(value)

Asserts that a string tag starts with the given value.

  • Credit cost: 0
  • Parameters:
    • value: Must be a String type
  • Returns: BooleanFilter



StringFilter.ends_with

Usage: filter.ends_with(value)

Asserts that a string tag ends with the given value.

  • Credit cost: 0
  • Parameters:
    • value: Must be a String type
  • Returns: BooleanFilter



Sample Code


import Filter

# asserts 'bpm' == 120
Filter.numeric_tag('raw.bpm').equal_to(120)

# asserts 'name' != 'Joe'
Filter.string_tag('raw.name').not_equal_to('Joe')

# asserts 'age' > 20 and 'bpm' > 80
age_filter = Filter.numeric_tag('age').greater_than(20)
bpm_filter = Filter.numeric_tag('bpm').greater_than(80)
comb_filter = age_filter & bpm_filter