your1/qdrant
Composer 安装命令:
composer require your1/qdrant
包简介
PHP Client for Qdrant
README 文档
README
Note;
This is a ported version for PHP7.4!
Qdrant is a vector similarity engine & vector database. It deploys as an API service providing search for the nearest high-dimensional vectors. With Qdrant, embeddings or neural network encoders can be turned into full-fledged applications for matching, searching, recommending, and much more!
Installation
You can install the client in your PHP project using composer:
composer require your1/qdrant
An example to create a collection :
use Qdrant\Endpoints\Collections; use Qdrant\Http\GuzzleClient; use Qdrant\Models\Request\CreateCollection; use Qdrant\Models\Request\VectorParams; include __DIR__ . "/../vendor/autoload.php"; include_once 'config.php'; $config = new \Qdrant\Config(QDRANT_HOST); $config->setApiKey(QDRANT_API_KEY); $client = new Qdrant(new GuzzleClient($config)); $createCollection = new CreateCollection(); $createCollection->addVector(new VectorParams(1024, VectorParams::DISTANCE_COSINE), 'image'); $response = $client->collections('images')->create($createCollection);
So now, we can insert a point :
use Qdrant\Models\PointsStruct; use Qdrant\Models\PointStruct; use Qdrant\Models\VectorStruct; $points = new PointsStruct(); $points->addPoint( new PointStruct( (int) $imageId, new VectorStruct($data['embeddings'][0], 'image'), [ 'id' => 1, 'meta' => 'Meta data' ] ) ); $client->collections('images')->points()->upsert($points);
While upsert data, if you want to wait for upsert to actually happen, you can use query paramaters:
$client->collections('images')->points()->upsert($points, ['wait' => 'true']);
You can check for more parameters : https://qdrant.github.io/qdrant/redoc/index.html#tag/points/operation/upsert_points
Search with a filter :
use Qdrant\Models\Filter\Condition\MatchString; use Qdrant\Models\Filter\Filter; use Qdrant\Models\Request\SearchRequest; use Qdrant\Models\VectorStruct; $searchRequest = (new SearchRequest(new VectorStruct($embedding, 'elev_pitch'))) ->setFilter( (new Filter())->addMust( new MatchString('name', 'Palm') ) ) ->setLimit(10) ->setParams([ 'hnsw_ef' => 128, 'exact' => false, ]) ->setWithPayload(true); $response = $client->collections('images')->points()->search($searchRequest);
your1/qdrant 适用场景与选型建议
your1/qdrant 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 3.48k 次下载、GitHub Stars 达 3, 最近一次更新时间为 2023 年 12 月 13 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 your1/qdrant 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 your1/qdrant 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 3.48k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 3
- 点击次数: 11
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2023-12-13