For the complete documentation index, see llms.txt. This page is also available as Markdown.

Vector Store

Neuron provides you with ready to use components to connect your agent to vector databases.

We currently offer first-party support for the following vector store:

Memory

This is an implementation of a volatile vector store that keeps your embeddings into the machine memory for the current session. It's useful when you don't need to store the generated embeddings for long term use, but just during current interaction sessions (or for local use).

namespace App\Neuron;

use NeuronAI\RAG\RAG;
use NeuronAI\RAG\VectorStore\MemoryVectorStore;
use NeuronAI\RAG\VectorStore\VectorStoreInterface;

class MyChatBot extends RAG
{
    ...

    protected function vectorStore(): VectorStoreInterface
    {
        return new MemoryVectorStore();
    }
}

File

File storage could be useful for low volume use case or local and staging environments. Embedded documents will be stored in the file system and processed during similarity search.

FileVectorStore uses PHP generators to read the embedded documents from the file systems. It will never keep more than topK items in memory while iterating very fast. You can store thousands of documents in your local filesystem only taking care on the maximum time you can accept to perform the similarity search.

You can also use this component to release agents with some knowledge already incorporated in a file.

PHPVector

PHPVector adapter on top of ezimuel/phpvector. It is a pure-PHP vector database implementing HNSW (Hierarchical Navigable Small World) for approximate nearest-neighbour search and BM25 for full-text retrieval. Both engines can be combined into a single hybrid search pipeline.

You can install the component with composer:

Use it in a RAG context:

MariaDB

MariaDB supports VECTOR column type starting from version 11.7. To make this component works you need to create the table to store documents and related vectors. Here is the SQL script you can use to do so:

Here is how to use the component in your RAG:

Pinecone

Pinecone makes it easy to provide long-term memory for high-performance AI applications. It’s a managed, cloud-native vector database with a simple API and no infrastructure hassles. Pinecone serves fresh, filtered query results with low latency at the scale of billions of vectors.

Here is how to use Pinecone in your agent:

Weaviate

Elasticsearch

Elasticsearch's open source vector database offers an efficient way to create, store, and search vector embeddings. To use Elasticseach as a vector store in your agents implementation you have to import the official client:

Here is how to create a RAG that uses Elasticsearch:

OpenSearch

Opensearch is the pure open source alternative to Elasticsearch. To use Opensearch in your agents you need to install its official client:

Once you have the official client installed in your app you can return an instance of the OpenSearchVectorStore in your RAG agent:

Typesense

Typesense is an open source alternative to the options above. To use Typesense in your agents you need to install its official client:

Once you have the official client installed in your app you can return an instance of the TypesenseVectorStore in your RAG agent:

Qdrant

Qdrant is an open source vector database with strong similarity search capabilities. To use Qdrant in your agents you have to provide a collectionUrl. This means you will first need to create a collection on Qdrant with its attributes like: name, similarity search algorithm, vector dimension, etc.

Once you have the collection URL you can attach the QdrantVectorStore instance to your agent.

ChromaDB

Chroma is an open source database designed to be an AI application data source. To use ChromaDB in your agents you have to provide the name of an internal collection where you want to store the embeddings.

Once you have the collection created on your Chroma instance you can attach the ChromaVectorStore instance to the agent:

Meilisearch

Meilisearch is a hybrid search engine, but the Neuron implementation uses it exclusively as a vector store for embeddings and similarity search.

The indexUid parameter should be the identifier of a Meilisearch index that you have created and configured. Make sure this index defines a vector field whose dimension matches the embedding size produced by the embedder you are using. The embedder value (for example, default) must correspond to a named embedder configured in your Neuron setup so that the stored vectors and the index configuration stay aligned. Add the component to your RAG:

MongoDB

To use this component you need to install the official mongoDB client:

Use the component in you RAG or script:

Extend Vector Stores

If you want to support a new vector store you have to implement VectorStoreInterface:

There are two different methods for adding a single document or a collection of documents because many databases provide different APIs for these use cases. If the database you want to interact to doesn't handle these requests differently you can implement addDocuments() as a placeholder o addDocument().

The search() method should return the list of documents with a similarity score not a similarity distance. If the underlying database returns a distance you can convert it to a score using the utility class VectorSimilarity:

After creating your own implementation you can use it in the agent as any other store:

Filters

DocumentSchema

Document is the unified processing object across loading, splitting, embedding, storage, retrieval, middleware, and reranking. Its fields are accessed through methods. Embedding and score are nullable runtime values; strict null checks express whether a stage produced them (0.0 remains a valid score).

Custom metadata stays schema-less for storage and round-tripping. Portable filtering requires a collection-level schema passed to the vector store:

Stores validate declared values and filters locally. Only sourceType, sourceName, and declared filterable metadata fields are portable filter targets. Array fields are supported for validation/storage but need raw backend filters except for portable filterable string arrays, which support containsAny and containsAll. Declared arrays must be non-empty homogeneous lists. A DocumentField can be passed directly to filter factories for schema-aware construction. neq requires a required field so missing-field behavior cannot diverge between databases. RAG validates documents before embedding.

Filter Expression

Once you have deined ilterable fields with DocumentSchema, you can pass a filtering expression to the retriaval strategy at runtime.

Filter are a portable, backend-neutral expression tree compiled to each store's native syntax. This is filtered similarity search: metadata filters constrain vector similarity results. Reserve hybrid search for strategies that combine vector and lexical ranking.

Available Filters

Filter::eq/neq/in/gt/gte/lt/lte(field, value) — low-level comparison factories.

Filter::where(field, value) starts an immutable fluent Criteria with where* methods for the common path. Values are scalars only (null throws: no portable missing-vs-null semantics); range values normalize to int|float (string ranges are not portable). Backed enums normalize to their value and DateTimeInterface values normalize to epoch timestamps.

FilterGroup::allOf(...) / anyOf(...) — nested boolean expressions; and(...) / or(...) remain short aliases. Same-operator groups flatten, while mixed operators preserve their boundaries.

Filter::containsAny/containsAll(field, values) — portable filtering for filterable string[] fields. Other array types remain backend-native.

Filter::raw(StoreClass::class, $fragment) — backend-native escape hatch, tagged with its target store. The tagged store passes the fragment through verbatim; every other store's compiler throws (fail-loud on store swap, never silent misfiltering). Raw fragments must be trusted, developer-authored syntax; never interpolate request values into them.

FilterScope::merge(...) — combines independently supplied mandatory scopes with a root AND. Query expressiveness and scope safety are separate.

FilterGroup::allOf(...) / anyOf(...) — nested boolean expressions; and(...) / or(...) remain short aliases. Same-operator groups flatten, while mixed operators preserve their boundaries.

Last updated