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

HTTP client query method is not working as expected #342

Open
arrrrny opened this issue Jul 18, 2024 · 7 comments
Open

HTTP client query method is not working as expected #342

arrrrny opened this issue Jul 18, 2024 · 7 comments
Assignees

Comments

@arrrrny
Copy link

arrrrny commented Jul 18, 2024

Describe the bug:

When using the httpClient to query the collection, first thing is that filter field is optional on HttpVectorQueryReq but gets an error from the api as being required.

export interface HttpVectorQueryReq extends HttpBaseReq {
outputFields: string[];
filter?: string;
limit?: number;
offset?: number;
params?: Record<string, string | number>;
}

Steps to reproduce:

I passed in filter as empty string filter: " " and it worked however, it does not obey the params at all.

I have a zikzakId field which I want to query the data by and it works if I pass it to the method as filter: "zikzakId == 248" .
return this.apiClient.query({
filter: "zikzakId == 248",
dbName: dbName,
collectionName: collectionName,
outputFields: ["*"],
params: params,
});

Expected behaviour is params to be doing the actual querying
params { zikzakId: 248 }

return this.apiClient.query({
  filter: " ",
  dbName: dbName,
  collectionName: collectionName,
  outputFields: ["*"],
  params: params,
});

At this point params do nothing

Milvus-node-sdk version:
2.4.4
Milvus version:
2.4.4

@zhanshuyou
Copy link
Contributor

@arrrrny
This is a Milvus issue. Milvus 2.4.6 has fixed this issue. Please upgrade Milvus and give it a try.

@arrrrny
Copy link
Author

arrrrny commented Jul 21, 2024

@zhanshuyou I upgraded to 2.4.6 and issue still persists.

My use case is, my collection have zikzakId. I want to get the item with the zikzakId.

return this.apiClient.query({
  dbName:dbName,
  collectionName:collectionName,
  outputFields: ["*"],
  params:  { zikzakId:148278},
});

Above does not return any data.

If I query it from the milvus client, NOT HttpClient as below. it works

return this.client.query({
  filter: 'zikzakId == 148278',
  collection_name: collectionName,
  output_fields: ["*"],
});

@zhanshuyou
Copy link
Contributor

@arrrrny Okay, I will check on HttpClient. I will get back to you when there is a conclusion.

@zhanshuyou
Copy link
Contributor

@arrrrny
HttpClient has a type error, it indeed does not support the params field, I will fix it.
types should be:
{
"dbName": "string",
"collectionName": "string",
"filter": "string",
"outputFields": [],
"partitionNames": []
}

@arrrrny
Copy link
Author

arrrrny commented Jul 22, 2024

@zhanshuyou It would be sweet to keep the params as is and have a conversion into a filter before sending it to the server. Since params can only assign values to a specific fields. you can convert them as whatever comes on the params, chain them with && and in the end && with the string on the filter.
so if I send params as

{ zikzakId:6, barcode:'8691234567'} it can indeed convert this into a filter as zikzakId==6 && barcode =='8691234567' and if the filter field is not empty use && with what ever comes from the filter.

@zhanshuyou
Copy link
Contributor

@arrrrny
Currently, converting params to filter only supports the == operator, which is not universal. We still need to think about it more. Thank you for your suggestion.

@arrrrny
Copy link
Author

arrrrny commented Jul 22, 2024

@zhanshuyou thats also all that is possible. a param is only an equality. it can be chanined and add to the tail of the filter string with an && operator. Thats how I handle on my end.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants