LogoLogo
  • 🔬Activeloop
  • 🏠Setup
    • Quickstart
  • Models & Pricing
  • 📖User Guide
    • Ingesting with Metadata
      • Modalities
    • Filtering Query
      • Query Syntax
    • Streaming Output
  • 🏗️API Reference
    • Chat Completions
    • Files
Powered by GitBook
On this page
  • Basic Syntax
  • Supported Operators
  • Data Types
  • Logical Operators
  • Accessing Nested Properties
  • Examples
  • Basic Comparisons
  • Combining Conditions
  • Working with Lists
  • Pattern Matching
  • Null Checks
  • Nested Properties
  • Complex Filters
  • Reserved Keywords
  • Best Practices
Export as PDF
  1. User Guide
  2. Filtering Query

Query Syntax

Cheatsheet for filtering the data

Basic Syntax

A filter expression consists of one or more conditions that can be combined using logical operators. Each condition typically follows this pattern:

column operator value

Supported Operators

Operator
Description
Example

=, ==

Equals

name = "John"

!=, <>

Not equals

status != "inactive"

>

Greater than

age > 30

>=

Greater than or equal to

price >= 100

<

Less than

quantity < 5

<=

Less than or equal to

temperature <= 32

in

Value is in a list

status in ["active", "pending"]

like

Pattern matching

name like "%Smith%"

is null

Value is null

address is null

is not null

Value is not null

email is not null

Data Types

The syntax supports the following data types:

  • Strings: Enclosed in double quotes ("value") or single quotes ('value')

  • Numbers: Integers or decimals (42, 3.14)

  • Booleans: true or false

  • Lists: Enclosed in square brackets, with comma-separated values ([1, 2, 3], ["active", "pending"])

Logical Operators

Conditions can be combined using logical operators:

  • AND: condition1 and condition2

  • OR: condition1 or condition2

Parentheses can be used to group conditions and control precedence:

(age > 30 and status = "active") or role = "admin"

Accessing Nested Properties

For nested data structures, use dot notation to access properties:

user.profile.name = "John"
metadata.tags[0] = "important"

Examples

Basic Comparisons

// Simple equality check
name = "John"

// Numeric comparison
age > 30

// Boolean value
is_active = true

Combining Conditions

// Using AND
age > 30 and status = "active"

// Using OR
status = "pending" or status = "in_review"

// Combining with parentheses
(age > 30 and status = "active") or role = "admin"

Working with Lists

// Check if value is in a list
status in ["active", "pending", "in_review"]

// Empty list
tags in []

Pattern Matching

// Names that contain "Smith"
name like "%Smith%"

// Email addresses from a specific domain
email like "%@example.com"

// Starts with a specific prefix
product_code like "ABC%"

Null Checks

// Check if a field is null
address is null

// Check if a field is not null
email is not null

Nested Properties

// Access nested object properties
user.profile.address = "New York"

// Access array elements
metadata.tags[0] = "important"

// Deep nesting
order.items[0].product.name = "Widget"

Complex Filters

// Complex filter combining multiple conditions
(status in ["active", "pending"] and created_date > "2023-01-01") or
(is_priority = true and (assigned_to = "John" or assigned_to is null))

Reserved Keywords

The following keywords are reserved and should not be used as field names:

  • and

  • or

  • in

  • like

  • is

  • null

  • not

  • true

  • false

Best Practices

  1. Use parentheses to make complex expressions clearer

  2. Be consistent with string quotes (prefer double quotes)

  3. Use whitespace to improve readability

  4. For complex filters, break expressions into multiple lines

PreviousFiltering QueryNextStreaming Output

Last updated 12 days ago

📖