HTTP client query method is not working as expected
arrrrny opened this issue · 7 comments
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
@arrrrny
This is a Milvus issue. Milvus 2.4.6 has fixed this issue. Please upgrade Milvus and give it a try.
@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: ["*"],
});
@arrrrny Okay, I will check on HttpClient. I will get back to you when there is a conclusion.
@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": []
}
@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.
@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.
@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.