What this prompt does
This prompt makes the AI implement a full-text search system with Laravel Scout, spanning [record_count] records across [model_count] models using [search_engine]. It configures Scout, sets [queue_setting] indexing, and tunes global settings like [typo_tolerance], stop words for [language], and [ranking_rules]. Stating the record count and engine lets the AI size the index and plan reindexing rather than producing a setup that works on a handful of rows but stalls at scale.
The structure works because good search is the sum of these decisions. Each model in [searchable_models] gets a toSearchableArray() using [field_strategy] with flattened relationships and shouldBeSearchable() to skip [exclude_criteria]; per-index settings define [facet_fields], [sort_fields], and [synonym_groups]; the API exposes [search_features] like facet counts and suggestions; and a [frontend_component] debounced at [debounce_ms] drives the UX. The optimization step targets [latency_target] and zero-downtime reindexing via [reindex_strategy]. Declaring [record_count] and [queue_setting] lets the AI decide between sync and queued indexing and size scout:import chunks with [chunk_size] so a full reindex does not exhaust memory. The SearchController exposes the [search_features] you ask for — multi-index search, facet counts, highlighted snippets, and did-you-mean suggestions for zero-result queries — and the [debounce_ms] setting on the [frontend_component] keeps the instant-results dropdown from firing a request on every keystroke. Edge cases like soft-deleted records and polymorphic search are handled explicitly rather than left to break later.
When to use it
- You need fast, typo-tolerant search across multiple models in a Laravel app
- You want faceted filtering and facet counts in a search sidebar
- You need queued indexing in production with sync indexing locally
- You want did-you-mean suggestions for zero-result queries
- You need zero-downtime reindexing after a data migration
- You want to keep search latency low by trimming the index payload deliberately
Example output
The AI returns Scout and [search_engine] configuration, toSearchableArray() and shouldBeSearchable() implementations for each model in [searchable_models], per-index settings for searchable attributes, [facet_fields], [sort_fields], and [synonym_groups], a SearchController with multi-index search, facet counts, highlighted snippets, and suggestions, a [frontend_component] with debounced input and a faceted sidebar, plus optimization steps including index warming, scout:import with chunk size [chunk_size], and [reindex_strategy] for zero-downtime reindexing.
Pro tips
- Order
[field_strategy]weights so titles outrank body text; relevance is mostly attribute priority - Trim stored attributes toward
[size_reduction_target]— excluding body HTML is what keeps[latency_target]reachable - Define
[synonym_groups]for your domain (JS/JavaScript, auth/authentication) so searchers find results regardless of phrasing - Use
shouldBeSearchable()with[exclude_criteria]so drafts and archived records never leak into results - Tune
[chunk_size]forscout:importto balance reindex speed against memory on your box - Always plan
[reindex_strategy](index swapping) so a full reindex never serves empty results to live users