# Query Language

**Last Updated:** 2026-02-19
**Confidence:** High

## Summary

The query interface is a single operation that encapsulates candidate retrieval, filtering, ranking, and diversity enforcement. Three primary operations: RETRIEVE (feed/browse), SEARCH (text+semantic), and SIGNAL (engagement write-back).

**Key Facts:**
- One query replaces what currently requires 6 systems
- RETRIEVE: feed generation, browse, related content
- SEARCH: keyword + semantic + hybrid retrieval
- SIGNAL: engagement event write-back (closes the feedback loop in the same transaction)
- All queries accept: FOR USER, USING PROFILE, FILTER, DIVERSITY, LIMIT
- Filters are composable — any combination is valid

**File Pointer:** `VISION.md:47-57`

## Query Shapes

**Feed retrieval:**
```
RETRIEVE items
FOR USER @user_id
CONTEXT feed
USING PROFILE for_you
FILTER unseen, unblocked, format:video
DIVERSITY max_per_creator:2, format_mix:true
LIMIT 50
```

**Search:**
```
SEARCH items
QUERY "rust tutorial beginner"
VECTOR query_vector
FOR USER @user_id
USING PROFILE search
DIVERSITY max_per_creator:2
LIMIT 20
```

**Signal write:**
```
SIGNAL like
item: @item_id
user: @user_id
timestamp: now()
```

**Related content:**
```
RETRIEVE items
SIMILAR TO @item_id
FOR USER @user_id
USING PROFILE related
FILTER unseen
LIMIT 10
```

## Related Topics
- [Ranking Profiles](../services/ranking-profiles.md)
- [Filters](./filters.md)
- [Sort Modes](./sort-modes.md)
