Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v1.2.0 API #18

Merged
merged 5 commits into from
May 23, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"@changesets/cli": "2.26.1",
"husky": "8.0.3",
"is-ci": "3.0.1",
"lint-staged": "13.2.1",
IvanPleshkov marked this conversation as resolved.
Show resolved Hide resolved
"prettier": "2.8.7",
"typescript": "5.0.4"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/js-client-rest/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@qdrant/js-client-rest",
"version": "1.1.6",
"version": "1.2.0",
"engines": {
"node": ">=18.0.0",
"pnpm": ">=8"
Expand Down
32 changes: 32 additions & 0 deletions packages/js-client-rest/src/api/points-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,22 @@ export function createPointsApi(client: Client) {
.method('post')
.create({wait: true, ordering: true}),

/**
* Update vectors
*/
updateVectors: client
.path('/collections/{collection_name}/points/vectors')
.method('put')
.create({wait: true, ordering: true}),

/**
* Delete vectors
*/
deleteVectors: client
.path('/collections/{collection_name}/points/vectors/delete')
.method('post')
.create({wait: true, ordering: true}),

/**
* Retrieve full information of single point by id
*/
Expand Down Expand Up @@ -65,6 +81,14 @@ export function createPointsApi(client: Client) {
.method('post')
.create({consistency: true}),

/**
* Search point groups
*/
searchPointGroups: client
.path('/collections/{collection_name}/points/search/groups')
.method('post')
.create({consistency: true}),

/**
* Scroll request - paginate over all points which matches given filtering condition
*/
Expand Down Expand Up @@ -104,5 +128,13 @@ export function createPointsApi(client: Client) {
.path('/collections/{collection_name}/points')
.method('put')
.create({wait: true, ordering: true}),

/**
* Recommend point groups
*/
recommendPointGroups: client
.path('/collections/{collection_name}/points/recommend/groups')
.method('post')
.create({consistency: true}),
} as const;
}
440 changes: 402 additions & 38 deletions packages/js-client-rest/src/openapi/generated_schema.ts

Large diffs are not rendered by default.

197 changes: 197 additions & 0 deletions packages/js-client-rest/src/qdrant-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,203 @@ export class QdrantClient {
return maybe(response.data.result).orThrow('Count points returned empty');
}

/**
* Get cluster information for a collection.
* @param collection_name
* @returns Operation result
*/
async collectionClusterInfo(collection_name: string) {
const response = await this._openApiClient.collections.collectionClusterInfo({collection_name});
return maybe(response.data.result).orThrow('Collection cluster info returned empty');
}

/**
* Update vectors
* @param collection_name
* @param {object} args
* - wait: Await for the results to be processed.
* - If `true`, result will be returned only when all changes are applied
* - If `false`, result will be returned immediately after the confirmation of receiving.
* - Default: `true`
* - ordering: Define strategy for ordering of the points. Possible values:
* - 'weak' - write operations may be reordered, works faster, default
* - 'medium' - write operations go through dynamically selected leader,
* may be inconsistent for a short period of time in case of leader change
* - 'strong' - Write operations go through the permanent leader,
* consistent, but may be unavailable if leader is down
* - points: Points with named vectors
* @returns Operation result
*/
async updateVectors(
collection_name: string,
{
wait = true,
ordering,
points
}: {wait?: boolean; ordering?: SchemaFor<'WriteOrdering'>} & SchemaFor<'UpdateVectors'>,
) {
const response = await this._openApiClient.points.updateVectors({
collection_name,
wait,
ordering,
points,
});
return maybe(response.data.result).orThrow('Update vectors returned empty');
}

/**
* Delete vectors
* @param collection_name
* @param {object} args
* - wait: Await for the results to be processed.
* - If `true`, result will be returned only when all changes are applied
* - If `false`, result will be returned immediately after the confirmation of receiving.
* - Default: `true`
* - ordering: Define strategy for ordering of the points. Possible values:
* - 'weak' - write operations may be reordered, works faster, default
* - 'medium' - write operations go through dynamically selected leader,
* may be inconsistent for a short period of time in case of leader change
* - 'strong' - Write operations go through the permanent leader,
* consistent, but may be unavailable if leader is down
* - points: Deletes values from each point in this list
* - filter: Deletes values from points that satisfy this filter condition
* - vector: Vector names
* @returns Operation result
*/
async deleteVectors(
collection_name: string,
{
wait = true,
ordering,
points,
filter,
vector,
}: {wait?: boolean; ordering?: SchemaFor<'WriteOrdering'>} & SchemaFor<'DeleteVectors'>,
) {
const response = await this._openApiClient.points.deleteVectors({
collection_name,
wait,
ordering,
points,
filter,
vector,
});
return maybe(response.data.result).orThrow('Delete vectors returned empty');
}

/**
* Search point groups
* @param collection_name
* @param {object} args -
* - consistency: Read consistency of the search. Defines how many replicas should be queried before returning the result.
* Values:
* number - number of replicas to query, values should present in all queried replicas
* 'majority' - query all replicas, but return values present in the majority of replicas
* 'quorum' - query the majority of replicas, return values present in all of them
* 'all' - query all replicas, and return values present in all replicas
* - vector:
* - filter: Look only for points which satisfies this conditions
* - params: Additional search params
* - with_payload: Select which payload to return with the response
* - with_vector: Whether to return the point vector with the result?
* - score_threshold: Define a minimal score threshold for the result. If defined, less similar results will not be returned. Score of the returned result might be higher or smaller than the threshold depending on the Distance function used. E.g. for cosine similarity only higher scores will be returned.
* - group_by: Payload field to group by, must be a string or number field. If the field contains more than 1 value, all values will be used for grouping. One point can be in multiple groups.
* - group_size: Maximum amount of points to return per group
* - limit: Maximum amount of groups to return
* @returns Operation result
*/
async searchPointGroups(
collection_name: string,
{
consistency,
vector,
filter,
params,
with_payload = null,
with_vector = null,
score_threshold,
group_by,
group_size,
limit,
}: {consistency?: SchemaFor<'ReadConsistency'>} & SchemaFor<'SearchGroupsRequest'>,
) {
const response = await this._openApiClient.points.searchPointGroups({
collection_name,
consistency,
vector,
filter,
params,
with_payload,
with_vector,
score_threshold,
group_by,
group_size,
limit,
});
return maybe(response.data.result).orThrow('Search point groups returned empty');
}

/**
* Recommend point groups
* @param collection_name
* @param {object} args -
* - consistency: Read consistency of the search. Defines how many replicas should be queried before returning the result.
* Values:
* number - number of replicas to query, values should present in all queried replicas
* 'majority' - query all replicas, but return values present in the majority of replicas
* 'quorum' - query the majority of replicas, return values present in all of them
* 'all' - query all replicas, and return values present in all replicas
* - positive: Look for vectors closest to those
* - negative: Try to avoid vectors like this
* - filter: Look only for points which satisfies this conditions
* - params: Additional search params
* - with_payload: Select which payload to return with the response
* - with_vector: Whether to return the point vector with the result?
* - score_threshold: Define a minimal score threshold for the result. If defined, less similar results will not be returned. Score of the returned result might be higher or smaller than the threshold depending on the Distance function used. E.g. for cosine similarity only higher scores will be returned.
* - using: Define which vector to use for recommendation, if not specified - try to use default vector
* - lookup_from: The location used to lookup vectors. If not specified - use current collection. Note: the other collection should have the same vector size as the current collection
* - group_by: Payload field to group by, must be a string or number field. If the field contains more than 1 value, all values will be used for grouping. One point can be in multiple groups.
* - group_size: Maximum amount of points to return per group
* - limit: Maximum amount of groups to return
* @returns Operation result
*/
async recommendPointGroups(
collection_name: string,
{
consistency,
positive,
negative = [],
filter,
params,
with_payload = null,
with_vector = null,
score_threshold,
using = null,
lookup_from = null,
group_by,
group_size,
limit,
}: {consistency?: SchemaFor<'ReadConsistency'>} & SchemaFor<'RecommendGroupsRequest'>,
) {
const response = await this._openApiClient.points.recommendPointGroups({
collection_name,
consistency,
positive,
negative,
filter,
params,
with_payload,
with_vector,
score_threshold,
using,
lookup_from,
group_by,
group_size,
limit,
});
return maybe(response.data.result).orThrow('Recommend point groups API returned empty');
}

/**
* Update or insert a new point into the collection.
* @param collection_name
Expand Down
4 changes: 2 additions & 2 deletions packages/qdrant-js/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@qdrant/qdrant-js",
"version": "1.1.6",
"version": "1.2.0",
"engines": {
"node": ">=18.0.0",
"pnpm": ">=8"
Expand Down Expand Up @@ -42,7 +42,7 @@
"clean": "rimraf ./dist"
},
"dependencies": {
"@qdrant/js-client-rest": "workspace:1.1.6"
"@qdrant/js-client-rest": "workspace:1.2.0"
},
"devDependencies": {
"@rollup/plugin-node-resolve": "15.0.2",
Expand Down
5 changes: 4 additions & 1 deletion pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.