symfony/ai-elasticsearch-store
Elasticsearch Store integrates Elasticsearch as a vector store for Symfony AI Store. It supports kNN vector search using dense_vector fields, enabling similarity search and retrieval over embeddings with Elasticsearch-backed indexing and querying.
symfony/ai-platform). Laravel’s service container can host the Elasticsearch store as a service provider, abstracting Symfony dependencies. The StoreInterface alignment ensures compatibility with Laravel’s AI workflows (e.g., RAG, embeddings).dense_vector field and k-NN search optimize for high-dimensional embeddings (e.g., 768–4096 dimensions from LLMs like Mistral or OpenAI).category: "books" + similarity > 0.8), enabling use cases like domain-specific retrieval (e.g., "Find technical docs similar to this query").elasticsearch/elasticsearch) in config/services.php.dense_vector mappings (e.g., via Laravel migrations or Elasticsearch API).composer require symfony/ai-platform.AppServiceProvider:
$this->app->bind(\Symfony\Component\AI\StoreInterface::class, \Symfony\Component\AI\Elasticsearch\Store::class);
pgvector, this avoids PostgreSQL lock-in, useful for teams already using Elasticsearch for search/logs.dense_vector precision or sharding) can break vector operations. Laravel teams unfamiliar with Elasticsearch may need dedicated setup docs or a pre-configured Docker stack.symfony/ai-store:^0.9 may require forking or wrapping for Laravel-specific needs (e.g., custom event listeners).knn: true). For production, benchmark:
?knn=false for exact search (slower but precise).replicas/shards for high-QPS workloads (e.g., real-time recommendations).pgvector or Weaviate?symfony/ai-platform without major refactoring?user_id, timestamp)? Elasticsearch’s query DSL supports complex filtering.knn: false) may be needed.symfony/ai-platform for full compatibility. Requires minimal changes if already using Symfony components.// app/Providers/ElasticsearchStoreServiceProvider.php
namespace App\Providers;
use Symfony\Component\AI\Elasticsearch\Store;
use Illuminate\Support\ServiceProvider;
class ElasticsearchStoreServiceProvider extends ServiceProvider {
public function register() {
$this->app->singleton(\Symfony\Component\AI\StoreInterface::class, function ($app) {
return new Store(
$app->make(\Elastic\Clients\ElasticsearchClient::class),
'vector_index',
'embedding_field'
);
});
}
}
composer require elasticsearch/elasticsearch
config/services.php:
'elasticsearch' => [
'hosts' => [
['host' => 'localhost', 'port' => 9200],
],
],
// Example: Create index with `dense_vector` field
$client = Elasticsearch::client();
$params = [
'index' => 'vector_index',
'body' => [
'mappings' => [
'properties' => [
'embedding' => ['type' => 'dense_vector', 'dims' => 768],
'metadata' => ['properties' => ['title' => ['type' => 'text']]],
],
],
],
];
$client->indices()->create($params);
pgvector).dense_vector, metadata fields).symfony/ai-store:^0.9. Check for backward compatibility with Laravel’s DI container.symfony/ai-memory-store for testing) via interface injection.symfony/ai-platform or custom store wrapper installed.dense_vector index with metadata fields.Store::nearest()).How can I help you explore Laravel packages today?