> ## Documentation Index
> Fetch the complete documentation index at: https://onetest.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# OQL Overview

> OneTest Query Language for powerful test searches

**OQL (OneTest Query Language)** is a simple, powerful way to search and filter tests. It's inspired by JQL (Jira Query Language) and designed to feel natural while giving you precise control.

## Why Use OQL?

> [card] Precise Control
>
> Filter by exact criteria, not fuzzy matches

> [card] Save Queries
>
> Save complex searches for reuse

> [card] Combine Conditions
>
> Use AND, OR, NOT for complex filters

> [card] Fast & Efficient
>
> Optimized queries execute instantly

## Quick Examples

```oql Simple Filter theme={null}
status = active
```

```oql Multiple Conditions theme={null}
status = active AND priority IN (p1, p2)
```

```oql Pattern Matching theme={null}
title ~ "login" AND scope ^ "auth"
```

```oql Date Queries theme={null}
created_at >= -7d ORDER BY created_at DESC
```

```oql Arrays theme={null}
tags CONTAINS "smoke" AND tags NOT CONTAINS "deprecated"
```

## Basic Syntax

> [tab] Comparisons
>
> Compare fields to values:
>
> | Operator | Meaning | Example |
> | - | - | - |
> | `=` | Equals | `status = active` |
> | `!=` | Not equals | `priority != p4` |
> | `>` | Greater than | `created_at > 2024-01-01` |
> | `>=` | Greater or equal | `version >= 2.0` |
> | `<` | Less than | `priority < p2` |
> | `<=` | Less or equal | `updated_at <= -7d` |

> [tab] Pattern Matching
>
> Match text patterns:
>
> | Operator | Meaning | Example |
> | - | - | - |
> | `~` | Contains | `title ~ "login"` |
> | `^ ` | Starts with | `identifier ^ "TC-10"` |
> | `$` | Ends with | `title $ "test"` |
> | `!~` | Not contains | `description !~ "deprecated"` |

> [tab] Arrays
>
> Work with lists:
>
> | Operator | Meaning | Example |
> | - | - | - |
> | `IN` | Value in list | `priority IN (p1, p2)` |
> | `NOT IN` | Value not in list | `status NOT IN (archived, deleted)` |
> | `CONTAINS` | Array contains value | `tags CONTAINS "smoke"` |
> | `CONTAINS ANY` | Array contains any value | `tags CONTAINS ANY (smoke, regression)` |
> | `CONTAINS ALL` | Array contains all values | `tags CONTAINS ALL (smoke, critical)` |

> [tab] Logic
>
> Combine conditions:
>
> | Operator | Meaning | Example |
> | - | - | - |
> | `AND` | Both conditions | `status = active AND priority = p1` |
> | `OR` | Either condition | `priority = p1 OR priority = p2` |
> | `NOT` | Negate condition | `NOT status = archived` |
> | `( )` | Group conditions | `(status = active OR status = approved) AND priority = p1` |

## Common Queries

> [accordion] Find Failed Tests
>
> ```oql theme={null}
> status = failed AND last_run >= -7d
> ```
>
> Find tests that failed in the last 7 days.

> [accordion] Smoke Tests
>
> ```oql theme={null}
> tags CONTAINS "smoke" AND status = active
> ORDER BY priority
> ```
>
> All active smoke tests, ordered by priority.

> [accordion] High Priority Tests
>
> ```oql theme={null}
> priority IN (p0, p1) AND status != archived
> ORDER BY created_at DESC
> ```
>
> All P0 and P1 tests that aren't archived.

> [accordion] Recently Updated
>
> ```oql theme={null}
> updated_at >= -14d
> ORDER BY updated_at DESC
> LIMIT 50
> ```
>
> Tests updated in the last 2 weeks.

> [accordion] Never Run
>
> ```oql theme={null}
> last_run IS NULL AND status = active
> ```
>
> Active tests that have never been executed.

> [accordion] Specific Feature
>
> ```oql theme={null}
> folder_path ~ "/authentication/" AND
> (tags CONTAINS "smoke" OR priority = p1)
> ```
>
> Important authentication tests.

## Date & Time Queries

OQL supports flexible date queries:

> [tab] Relative Dates
>
> ```oql theme={null}
> created_at >= -7d        # Last 7 days
> created_at >= -2w        # Last 2 weeks
> created_at >= -3M        # Last 3 months
> created_at >= -1y        # Last year
> ```

> [tab] Specific Dates
>
> ```oql theme={null}
> created_at >= 2024-01-01
> created_at BETWEEN 2024-01-01 AND 2024-12-31
> updated_at = 2024-06-15
> ```

> [tab] Date Functions
>
> ```oql theme={null}
> created_at >= startOfWeek()
> created_at >= startOfMonth()
> created_at >= startOfYear()
> created_at <= endOfMonth()
> ```

> [tab] Time Comparisons
>
> ```oql theme={null}
> updated_at > created_at
> last_run >= updated_at
> ```

## Sorting & Pagination

Control result order and size:

```oql theme={null}
# Sort by single field
ORDER BY created_at DESC

# Sort by multiple fields
ORDER BY priority ASC, created_at DESC

# Limit results
LIMIT 50

# Pagination
LIMIT 50 OFFSET 100
```

## Saved Queries

Save frequently-used queries:

**1. Write Your Query**

```oql theme={null}
priority IN (p0, p1) AND status = active AND tags CONTAINS "smoke"
```

**2. Save with Name**

Click "Save Query" and give it a name:

```
Critical Smoke Tests
```

**3. Reuse Anytime**

Access from the "Saved Queries" dropdown

## Using with AI

> [!TIP]
>
> You don't need to write OQL manually! Just ask the AI:
>
> ```
> Show me high priority tests that failed recently
> ```
>
> The AI translates to:
>
> ```oql theme={null}
> priority IN (p0, p1) AND status = failed AND last_run >= -7d
> ```

## What's Next?

> [card] [Full Syntax Reference](https://onetest.ai/oql/syntax.md)
>
> Complete OQL syntax documentation

> [card] [Query Examples](https://onetest.ai/oql/examples.md)
>
> More real-world query examples

> [card] [Field Reference](https://onetest.ai/oql/field-reference.md)
>
> All searchable fields

> [card] [AI Search](https://onetest.ai/ai/search-tests.md)
>
> Let AI write queries for you


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.