Skip to content

Commit

Permalink
update error handling on offset
Browse files Browse the repository at this point in the history
  • Loading branch information
TristenHarr committed Jun 11, 2024
1 parent 9a804d3 commit 2effed6
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 7 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# Qdrant Connector Changelog
This changelog documents changes between release tags.

## [0.2.1] - 2024-05-10
* Updated error handling to throw an error when attempting to paginate across string ID's since offset only works with points with Integer ID's

## [0.2.0] - 2024-05-6
* Added support for multi-vector points

Expand Down
4 changes: 2 additions & 2 deletions connector-definition/connector-metadata.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
packagingDefinition:
type: PrebuiltDockerImage
dockerImage: ghcr.io/hasura/ndc-qdrant:v0.2.0
dockerImage: ghcr.io/hasura/ndc-qdrant:v0.2.1
supportedEnvironmentVariables:
- name: QDRANT_URL
description: The url for the Qdrant database
Expand All @@ -9,7 +9,7 @@ supportedEnvironmentVariables:
commands:
update:
type: Dockerized
dockerImage: ghcr.io/hasura/ndc-qdrant:v0.2.0
dockerImage: ghcr.io/hasura/ndc-qdrant:v0.2.1
commandArgs:
- update
dockerComposeWatch:
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ndc-qdrant",
"version": "0.2.0",
"version": "0.2.1",
"main": "index.js",
"scripts": {
"start": "ts-node ./src/index.ts serve --configuration=.",
Expand Down
13 changes: 13 additions & 0 deletions src/handlers/query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -656,17 +656,27 @@ export async function performQueries(
}[][];
// Scroll Queries are a list of scroll requests
// SearchQueries are a list of search requests and can be batched!
let hasOffset: boolean = false;
if (queryPlan.scrollQueries.length > 0) {
// Run the scrollQueries
let promises = queryPlan.scrollQueries.map(scrollQuery => {
if (scrollQuery.offset){
hasOffset = true;
}
return state.client.scroll(queryPlan.collectionName, scrollQuery);
});
results = (await Promise.all(promises)).map(r => r.points);
} else if (queryPlan.searchQueries.length > 0) {
// Run the searchQueries as a batch!
if (queryPlan.searchQueries[0].offset){
hasOffset = true;
}
results = await state.client.searchBatch(queryPlan.collectionName, { searches: queryPlan.searchQueries });
} else if (queryPlan.recommendQueries.length > 0) {
// Run the reccomendQueries as a batch!
if (queryPlan.recommendQueries[0].offset){
hasOffset = true;
}
results = await state.client.recommend_batch(queryPlan.collectionName,
{
searches: queryPlan.recommendQueries
Expand Down Expand Up @@ -708,6 +718,9 @@ export async function performQueries(
if (Object.keys(row).length > 0){
rows.push(row);
}
if (typeof p.id === "string" && hasOffset){
throw new Forbidden("Offset can only be used with points with Integer ID's", {});
}
}
if (rows.length > 0){
rowSet.rows = rows as {
Expand Down
2 changes: 0 additions & 2 deletions src/handlers/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ export function doGetSchema(objectTypes: { [k: string]: ObjectType }, collection
let collectionInfos: CollectionInfo[] = [];
let functionsInfo: FunctionInfo[] = [];
let proceduresInfo: ProcedureInfo[] = [];
console.log("GETTING SCHEMA");
console.log(collection_vectors);
for (const cn of Object.keys(objectTypes)){
if (collection_names.includes(cn)){
let ID_FIELD_TYPE = "Int";
Expand Down

0 comments on commit 2effed6

Please sign in to comment.