Skip to contents
library(queryBuilder)

The article describes default set of operators offered by queryBuilder. Each operator generates expression that can be use to perform various filtering operations.

listQueryOperators()
#> equal: ==
#> not_equal: !=
#> in: %in%
#> not_in: !`%in%`
#> less: <
#> less_or_equal: <=
#> greater: >
#> greater_or_equal: >=
#> between: queryBuilder::in_range
#> not_between: !queryBuilder::in_range
#> begins_with: startsWith
#> not_begins_with: !startsWith
#> contains: queryBuilder::in_string
#> not_contains: !queryBuilder::in_string
#> ends_with: endsWith
#> not_ends_with: !endsWith
#> is_empty: queryBuilder::is_empty
#> not_is_empty: !queryBuilder::is_empty
#> is_null: is.na
#> not_is_null: !is.na

Operators viable for any type of field:

equal - check if field elements equal the provided value

  • R method: ==.
  • Sample rule: queryRule(field = "cyl", operator = "equal", value = 1)
  • Sample rule as expression: cyl == 4
  • Argument value is required, should be a single value.

not_equal - check if field elements are different from the provided value

  • R method: !=.
  • Sample rule: queryRule(field = "cyl", operator = "not_equal", value = 1)
  • Sample rule as expression: cyl != 4
  • Argument value is required, should be a single value.

in - check if field elements matches the provided set of values

  • R method: `%in%`.
  • Sample rule: queryRule(field = "cyl", operator = "in", value = c(4, 6))
  • Sample rule as expression: cyl %in% c(4, 6)
  • Argument value is required, should be a non-empty vector.

not_in - check if field elements do not match the provided set of values

  • R method: !`%in%`.
  • Sample rule: queryRule(field = "cyl", operator = "not_in", value = c(4, 6))
  • Sample rule as expression: !cyl %in% c(4, 6)
  • Argument value is required, should be a non-empty vector.

is_null - check if field elements are missing (NA)

  • R method: is.na.
  • Sample rule: queryRule(field = "cyl", operator = "is_null")
  • Sample rule as expression: is.na(cyl)
  • Argument value is ignored.

not_is_null - check if field elements are different from the provided value

  • R method: !is.na.
  • Sample rule: queryRule(field = "cyl", operator = "not_is_null")
  • Sample rule as expression: !is.na(cyl)
  • Argument value is ignored.

Operators viable for numerical and date/time based fields:

less - check if field elements are lesser than the provided value

  • R method: <.
  • Sample rule: queryRule(field = "cyl", operator = "less", value = 6)
  • Sample rule as expression: cyl < 6
  • Argument value is required, should be a single value.

less_or_equal - check if field elements are lesser or equal the provided value

  • R method: <=.
  • Sample rule: queryRule(field = "cyl", operator = "less_or_equal", value = 6)
  • Sample rule as expression: cyl <= 6
  • Argument value is required, should be a single value.

greater - check if field elements are greater than the provided value

  • R method: >.
  • Sample rule: queryRule(field = "cyl", operator = "greater", value = 6)
  • Sample rule as expression: cyl > 6
  • Argument value is required, should be a single value.

greater_or_equal - check if field elements are greater or equal the provided value

  • R method: >=.
  • Sample rule: queryRule(field = "cyl", operator = "greater_or_equal", value = 6)
  • Sample rule as expression: cyl >= 6
  • Argument value is required, should be a single value.

between - check if field elements fit within the provided range (boundary excluded)

  • R method: queryBuilder::in_range.
  • Sample rule: queryRule(field = "cyl", operator = "between", value = c(4, 8))
  • Sample rule as expression: queryBuilder::in_range(cyl, c(4, 8))
  • Argument value is required, should be a non-empty vector.

not_between - check if field elements do not match the provided set of values (boundary included)

  • R method: !queryBuilder::in_range.
  • Sample rule: queryRule(field = "cyl", operator = "not_between", value = c(4, 8))
  • Sample rule as expression: !queryBuilder::in_range(cyl, c(4, 8))
  • Argument value is required, should be a non-empty vector.

Operators viable for character fields:

begins_with - check if field elements start with the provided string value

  • R method: startsWith.
  • Sample rule: queryRule(field = "Species", operator = "begins_with", value = "setos")
  • Sample rule as expression: startsWith(Species, "setos")
  • Argument value is required, should be a single character value.

not_begins_with - check if field elements do not start with the provided string value

  • R method: !startsWith.
  • Sample rule: queryRule(field = "Species", operator = "not_begins_with", value = "setos")
  • Sample rule as expression: !startsWith(Species, "setos")
  • Argument value is required, should be a single value.

contains - check if field elements start with the provided string value

  • R method: queryBuilder::in_string.
  • Sample rule: queryRule(field = "Species", operator = "contains", value = "setos")
  • Sample rule as expression: queryBuilder::in_string(Species, "setos")
  • Argument value is required, should be a single character value.

not_contains - check if field elements do not start with the provided string value

  • R method: !queryBuilder::in_string.
  • Sample rule: queryRule(field = "Species", operator = "not_contains", value = "etos")
  • Sample rule as expression: !queryBuilder::in_string(Species, "etos")
  • Argument value is required, should be a single value.

ends_with - check if field elements end with the provided string value

  • R method: endsWith.
  • Sample rule: queryRule(field = "Species", operator = "ends_with", value = "etosa")
  • Sample rule as expression: endsWith(Species, "etosa")
  • Argument value is required, should be a single character value.

not_ends_with - check if field elements do not end with the provided string value

  • R method: !startsWith.
  • Sample rule: queryRule(field = "Species", operator = "not_ends_with", value = "setos")
  • Sample rule as expression: !endsWith(Species, "etosa")
  • Argument value is required, should be a single value.

is_empty - check if field elements are an empty string

  • R method: queryBuilder::is_empty.
  • Sample rule: queryRule(field = "Species", operator = "is_empty")
  • Sample rule as expression: queryBuilder::is_empty(cyl)
  • Argument value is ignored.

not_is_empty - check if field elements are not an empty string

  • R method: !queryBuilder::is_empty.
  • Sample rule: queryRule(field = "Species", operator = "not_is_empty")
  • Sample rule as expression: !queryBuilder::is_empty(cyl)
  • Argument value is ignored.

In order to set custom operators please check setQueryOperators().