A complete, working Laravel 13 application that puts a Vue 3 search interface in front of an Opensolr index. Search is hybrid: keyword relevance and semantic similarity fused per document, so "sleepy pets" finds the article about cats napping. One page searches an Eloquent model through Laravel Scout, the other searches the whole index and can write a grounded answer from the top hits. Clone it and read it, or use it as the starting point for your own.
01 · What the sample shows
Hybrid search over the whole index
One call to embed_and_search: the query is embedded server-side, keyword and semantic scores are fused, and highlighting, spelling suggestions, facet counts and the Search Tuning saved for the index come back together.
Eloquent models through Laravel Scout
Article::search($q)->where('category', $c)->paginate(), exactly as Scout documents it. The Opensolr driver runs the hybrid query, scopes it to the model and turns the category into a Solr filter.
A grounded AI answer
The Ask AI button calls aiAnswer(): the platform retrieves the top hybrid hits for the question and writes an answer from them, shown as plain text next to its sources.
A Vue 3 front end on Vite
Two page components sharing one composable for request state. Highlights are rendered as text nodes with only the hits wrapped in <mark>, so nothing from the index ever reaches innerHTML.
02 · The repository
The complete source is on GitHub: github.com/phpcip/laravel-opensolr-search, and on Packagist as opensolr/laravel-opensolr-search.
Everything talks to Opensolr through one package, opensolr/laravel-scout-opensolr. There is no Solr client to configure, no schema to design and no embedding model to run. The API key stays on the server; the browser only talks to the application's own JSON endpoints, which are validated and rate limited.
03 · Getting it running
Create the project
composer create-project opensolr/laravel-opensolr-search my-search, then cd my-search. PHP 8.3 or newer. Working from a clone instead: composer install, cp .env.example .env, php artisan key:generate, php artisan migrate --seed.
Configured on creation
create-project copies .env.example to .env, generates the application key, creates the SQLite database and seeds twenty sample articles. The example file already points at the public demo account, so nothing needs editing to start.
Index the articles
php artisan opensolr:create-index creates a private vector index on the account and writes its name to .env; php artisan scout:import "App\Models\Article" pushes the articles there. They become searchable about a minute later.
Build and serve
npm install, npm run build, php artisan serve, then open http://localhost:8000.
The demo account is public and shared: anything created on it is deleted after 3 days, every index on it is visible to everyone, and the limits are 200 MB of bandwidth and 50 MB of disk per index. Its news index is read-only, which is why the sample keeps two settings: OPENSOLR_INDEX for the whole-index search and the AI answer, and OPENSOLR_SCOUT_INDEX for your models. On your own account leave the second one empty and one index serves both. For an index that is private and still there next week, register, create a vector-enabled index, and change three lines in .env. Nothing else in the code changes.
04 · The stack
| Component | Role |
|---|---|
| Laravel 13 | The PHP application framework, on PHP 8.3 or newer. |
| Laravel Scout | Makes Eloquent models searchable with one trait. |
| opensolr/laravel-scout-opensolr | The Scout driver and API client: hybrid search, ingestion, grounded answers. |
| Vue 3 + Vite | The search interface and its build. |
| Opensolr | The hosted index, the embeddings and the LLM behind it all. |
The first version of this sample, from 2019, used Solarium against a Solr endpoint directly with Laravel 6 and Vue 2. It is preserved in the repository's git history under the tag legacy-solarium.