plugins/laravel-expert/skills/laravel-vector-search/SKILL.md
Use when implementing semantic / vector search in Laravel 13 with PostgreSQL + pgvector. Covers schema setup, embedding workflow, and the new query builder methods (`whereVectorSimilarTo`, `selectVectorDistance`, etc.).
npx skillsauth add fusengine/agents laravel-vector-searchInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Before ANY implementation, use TeamCreate to spawn 3 agents:
laravel.com/docs/13.x/search + queries examplesAfter implementation, run fuse-ai-pilot:sniper for validation.
| Feature | Description |
|---------|-------------|
| PostgreSQL only | Requires pgvector extension; not available on MySQL/SQLite |
| Schema helper | Schema::ensureVectorExtensionExists() enables the extension |
| Query builder | whereVectorSimilarTo(), selectVectorDistance(), whereVectorDistanceLessThan(), orderByVectorDistance() |
| Auto-embedding | Pass a raw string and Laravel generates the embedding via AI SDK |
| Cosine similarity | Default distance; threshold via minSimilarity (0.0 - 1.0) |
pgsql connections - no fallback to MySQL/SQLitedatabase/migrations/
└── XXXX_create_documents_table.php # Schema::ensureVectorExtensionExists(), vector(1536) col, HNSW index
app/Models/
└── Document.php # casts embedding to array, uses whereVectorSimilarTo
app/Ai/Services/
└── VectorSearchService.php # encapsulates query + threshold logic
→ See Document-model.php.md for full example
| Topic | Reference | When to Consult |
|-------|-----------|-----------------|
| pgvector setup | pgvector-setup.md | Migrations + index creation |
| Embedding workflow | embeddings-workflow.md | Generating + persisting vectors |
| Query patterns | queries.md | whereVectorSimilarTo and friends |
| Template | When to Use | |----------|-------------| | Document-model.php.md | Eloquent model with vector column | | VectorSearchService.php.md | Reusable service |
Schema::ensureVectorExtensionExists();
Schema::create('documents', function (Blueprint $table) {
$table->id();
$table->text('content');
$table->vector('embedding', 1536);
$table->timestamps();
$table->vectorIndex('embedding', algorithm: 'hnsw');
});
$documents = Document::query()
->whereVectorSimilarTo('embedding', 'best wineries in Napa Valley', minSimilarity: 0.4)
->limit(10)
->get();
→ See VectorSearchService.php.md for complete example
minSimilarity 0.3-0.5 as a starting threshold; tune empiricallywhere() for hybrid filtering (date ranges, tenancy)Embeddings::for([...])vector column type for index supportdevelopment
Use when optimizing entity-based / semantic SEO 2026. Covers entity maps, Google Knowledge Graph resolution, salience scoring, passage-level ranking, about/sameAs/knowsAbout schema, Cloud Natural Language API validation.
development
Use when running SEO, GEO, schema, Core Web Vitals, sitemap, hreflang, E-E-A-T, AI Overviews, technical SEO, or structured data tasks. Covers full-site audits, single-page analysis, schema markup, content quality, AI search optimization, local SEO, sitemap/robots, internal linking, semantic clustering, and search experience.
development
Use when optimizing search experience (SXO). Covers intent matching, user personas, user stories, page-type analysis, dwell time, scroll depth, pogo-sticking prevention.
development
Use when optimizing local SEO. Covers Google Business Profile, NAP consistency, citations, reviews acquisition, Local Pack ranking, location pages, LocalBusiness schema.