Cursor prompt

Implement Search with Filtering

Full-text search with faceted filters, cursor pagination, debounced UI, and URL-persisted state.

Implement search for {{entity}} in {{project_name}}.

## Search fields: {{searchable_fields}}
## Filter dimensions: {{filter_options}}
## Database: {{database}}

### Backend: Search API
GET /api/search?q=&filters=&sort=&cursor=&limit=
- Full-text search using PostgreSQL tsvector with GIN index
- Filter support: exact match, multi-select (OR within dimension, AND across dimensions)
- Sort by: relevance (default), newest, oldest, {{sort_options}}
- Cursor-based pagination for consistency with live data
- Highlight matching terms: wrap matched text in <mark> tags

### PostgreSQL Full-Text Index
```sql
CREATE INDEX idx_{{table}}_search ON {{table}}
USING GIN(to_tsvector('english',
  coalesce({{tsvector_columns}}, '')
));
```
Update tsvector on write via application logic or DB trigger.

### Frontend: Search UI
- Debounce input: 300ms before firing API call
- Persist q + filters in URL query params (shareable, back-button friendly)
- Show total result count: "42 results"
- Filter sidebar: instant apply, no submit button needed
- Skeleton loading during search
- Empty state: "No results for '{{q}}'" with search suggestions

### Performance
- Cache frequent search results in Redis for 60 seconds
- Return only needed projection fields from DB (no SELECT *)

### Output
Search API route, useSearch hook, filter sidebar component, results list.

Fill in: {{entity}}, {{project_name}}, {{searchable_fields}}, {{filter_options}}, {{database}}, {{sort_options}}, {{table}}, {{tsvector_columns}}, {{q}}. In Loopy you fill these in a form and copy the finished prompt in one click.