Skip to content
Back to skills

Vector Semantic Search

ASecurity

Add semantic search with native vector queries (Laravel 13+); pgvector similarity clauses, embedding workflows, and hybrid search patterns

  • 147 stars
  • 0 votes
  • 0 copies
  • 2 views
  • Added September 6, 2026
databasessqltesting

Security analysis

A100/100

Scanned September 6, 2026

npx -y skills add jpcaparas/superpowers-laravel --skill vector-semantic-search --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Vector Semantic Search?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Vector Semantic Search
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/jpcaparas-vector-semantic-search/badge)](https://www.skillsdirectory.com/skills/jpcaparas-vector-semantic-search)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: laravel:vector-search
description: Add semantic search with native vector queries (Laravel 13+); pgvector similarity clauses, embedding workflows, and hybrid search patterns
---

# Semantic / Vector Search (Laravel 13+)

Use native vector query support to build semantic search on PostgreSQL + `pgvector`. Generate embeddings via the AI SDK and query them directly from the query builder.

## Commands

```
# Migration: vector column (requires pgvector extension)
Schema::table('documents', function (Blueprint $table) {
    $table->vector('embedding', dimensions: 1536);
});

# Generate an embedding
use Illuminate\Support\Str;
$embedding = Str::of('Best wineries in Napa Valley')->toEmbeddings();

# Similarity search from the query builder
$documents = DB::table('documents')
    ->whereVectorSimilarTo('embedding', 'Best wineries in Napa Valley')
    ->limit(10)
    ->get();
```

## Patterns

- Store embeddings alongside the source row; regenerate when source text changes (model observer or queued job)
- Always `limit()` similarity queries; unbounded vector scans are expensive
- Add a vector index (HNSW/IVFFlat) for large tables; measure recall vs speed trade-offs
- Combine vector similarity with conventional `where` filters (tenant, status, locale) to scope results
- Consider hybrid search: merge keyword matches with semantic results for better precision
- Keep embedding model/dimensions in config; changing models invalidates stored vectors

## Testing

- Fake embedding generation in tests; assert stored dimensions and invalidation triggers
- Integration test similarity queries against a Postgres service with pgvector enabled (skip gracefully if unavailable)

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.