symfony/ai-open-search-store
OpenSearch vector store integration for Symfony AI Store. Index and query embeddings using OpenSearch knn_vector fields and k‑NN/approximate k‑NN search. Links to OpenSearch docs and contribution resources in the main Symfony AI repo.
knn_vector for vector similarity search—is universally applicable to any PHP application needing embeddings-based retrieval.StoreInterface if Laravel tolerates Symfony dependencies.knn_vector is production-ready but requires tuning (e.g., engine for ANN, dimensionality limits).StoreInterface without tight coupling, or is a custom OpenSearch client wrapper preferable?spatie/laravel-ai, pgvector) that reduce dependency risk?knn_vector performance for the target embedding dimensionality (e.g., 768D)?knn_vector format?symfony/process, symfony/http-client) or with AI/ML vector search needs.pgvector).pgvector, Weaviate) for Laravel’s stack.composer require symfony/ai-open-search-store.StoreInterface:
// app/Facades/OpenSearchStore.php
namespace App\Facades;
use Illuminate\Support\Facades\Facade;
use App\Services\OpenSearchVectorStore;
class OpenSearchStore extends Facade {
protected static function getFacadeAccessor() { return OpenSearchVectorStore::class; }
}
OpenSearchVectorStore to wrap Symfony’s OpenSearchStore:
// app/Services/OpenSearchVectorStore.php
namespace App\Services;
use Symfony\Component\AI\Store\OpenSearchStore as SymfonyOpenSearchStore;
use OpenSearch\Client;
class OpenSearchVectorStore {
public function __construct(private Client $client) {}
public function nearest(array $vector, int $limit = 5) {
return (new SymfonyOpenSearchStore($this->client, 'vector_index'))
->nearest($vector, $limit);
}
}
knn_vector field:
curl -X PUT "localhost:9200/vector_index" -H 'Content-Type: application/json' -d'
{
"mappings": {
"properties": {
"embedding": { "type": "knn_vector", "dimension": 768 }
}
}
}'
OpenSearchVectorStore in AppServiceProvider:
public function register() {
$this->app->singleton(\App\Services\OpenSearchVectorStore::class, function ($app) {
return new \App\Services\OpenSearchVectorStore(
new \OpenSearch\Client([...])
);
});
}
use App\Facades\OpenSearchStore;
public function searchSimilarVectors(array $embedding) {
return OpenSearchStore::nearest($embedding, limit: 3);
}
^0.8.0) to avoid breaking changes.alias() in AppServiceProvider to avoid Symfony namespace collisions.vendor/symfony namespace if needed.knn_vector index.engine for ANN).symfony/ai-open-search-store (though sparse).README.md for onboarding.spatie/laravel-queue).How can I help you explore Laravel packages today?