Download the PHP package mcpuishor/qdrant-laravel without Composer
On this page you can find all versions of the php package mcpuishor/qdrant-laravel. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download mcpuishor/qdrant-laravel
More information about mcpuishor/qdrant-laravel
Files in mcpuishor/qdrant-laravel
Package qdrant-laravel
Short Description A fluent package to interact with Qdrant Vector Database
License MIT
Informations about the package qdrant-laravel
Qdrant for Laravel
Introduction
This package provides an elegant, fluent interface for interacting with the Qdrant Vector Database in Laravel. Qdrant is a vector similarity search engine that makes it easy to store and search for embeddings, making it ideal for AI-powered applications.
Key features:
- Simple collection management
- Fluent search API with filtering and grouping
- Efficient point operations (insert, upsert, delete)
- Vector operations (update, delete)
- Laravel Facade support
- Convenient payload handling
Installation
1. Install via Composer
2. Publish the Configuration File
This will create a config/qdrant-laravel.php
file where you can set your Qdrant connections and defaults.
3. Set Up Your .env
File
Update your .env
file with your Qdrant host details:
Configuration
The config/qdrant-laravel.php
file allows multiple connections:
Schema Management (Migrations)
Creating a new collection
A collection must contain at least one vector. An optional parameter options
can contain additional
parameters described as an associative array. See the Qdrant documentation for details. The options can be specified using arrays
or DataObjects defined in the package.
The response is a boolean value, unless an exception is thrown.
Creating a new collection on a different connection
You can switch the connection at runtime. The connection must be defined in the
config\qdrant-laravel.php
file.
Creating a collection with multiple vectors
A collection can contain multiple vectors per point. They need to be passed on to the Schema::create
as an array containing the definitions of each vector. The vectors can have different definitions. The
optional parameters can be specified using Data Objects defined in the package.
Deleting a collection
To delete a collection, you can call the delete
method on the Schema
facade.
It returns a Mcpuishor\QdrantLaravel\DTOs\Response
object.
Collection existence
To check if the collection defined in the config on the current connection exists:
At the same time, you can check the existence of a different collection on the same connection:
Updating a collection
Updating parameters on an existing collection can be done in a similar fashion to creating one. The parameters updated can be specified using arrays or Data Objects defined in the package.
Updating the collection defined in the config\qdrant-laravel.php
:
Indexing a collection
Indexes in a Qdrant vector collection are created on the payload for each vector. For more details see the Qdrant documentation.
Creating an index
To create a payload index over a field:
It returns true
if the operation was successful, or false
otherwise.
You can use dot notation to create indexes over nested fields.
By default, indexes are stored in memory. If you have large indexes, and they
need to be stored on the disk, you can use the ->onDisk()
method before
creating the index. Choose carefully when to store an index on the disk,
as this will introduce some latency in your future queries.
Parameterized integer indexes
Qdrant v1.8.0 has introduced a parameterized variant of the integer index.
To turn the parameterized index on you can call the ->parameterized()
method before creating an integer
index. This setting is used only for integer
fields
in the payload.
Values of the lookup
and range
can be toggled in the config\qdrant-laravel.php
file.
For more information on parameterized integer indexes and how they affect performance
check the Qdrant documentation
It returns true
if the operation was successful, or false
otherwise.
Full-text indexes
Qdrant supports full-text search for string payload. Full-text index allows you to filter points by the presence of a word or a phrase in the payload field.
It returns
trueif the operation was successful, or
false`` otherwise.
Deleting an index
It returns
trueif the operation was successful, or
false`` otherwise.
Searching
The package provides a fluent interface for searching vectors in your Qdrant collection.
Basic Vector Search
To perform a simple search with a vector:
Search by Point ID
You can also search for similar points to an existing point by its ID:
Including Payload and Vectors
Control what data is returned with your search results:
Pagination
Control the number of results and implement pagination:
Filtering Results
Apply filters to search results using the fluent filter API:
Grouping Results
Group search results by a payload field:
Batch Searching
Perform multiple searches in a single request:
Random Sampling
Get random points from the collection:
Using Named Vectors
If your collection has multiple named vectors, specify which one to use:
Recommendations
The package provides a recommendation system based on positive and negative examples.
Basic Recommendations
Get recommendations based on positive examples:
Positive and Negative Examples
Refine recommendations with both positive and negative examples:
Recommendation Strategy
Control how vectors are combined for recommendations:
Available strategies include:
AverageVectorStrategy::MEAN
- Simple average of vectorsAverageVectorStrategy::WEIGHTED
- Weighted average based on similarity
Point Operations
The package provides methods for managing points in your Qdrant collection.
Retrieving Points
Get points by their IDs:
Controlling Returned Data
Control what data is returned with the points:
Inserting Points
Insert a new point into the collection:
Upserting Points
Insert or update multiple points:
Deleting Points
Delete points by their IDs:
Autochunking
Efficiently handle large numbers of points with automatic chunking:
Vector Operations
The package provides methods for managing vectors in your Qdrant collection.
Updating Vectors
Update vectors for existing points:
Deleting Vectors
Delete vectors for specific points:
Artisan Commands
Creating a Collection with indexes
Rolling Back a Migration (Dropping Collection & Indexes)
Extending with Macros
The query builder and client are Macroable, allowing custom methods:
Conclusion
This package simplifies working with Qdrant in Laravel, making it easy to integrate vector search and AI-powered applications. Contributions are welcome!
License
This package is open-source and available under the MIT License.