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

fix binary vector in query #77

Merged
merged 2 commits into from
Jan 20, 2022
Merged
Show file tree
Hide file tree
Changes from all 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
8 changes: 7 additions & 1 deletion example/BinarySearch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ const test = async () => {
fields_data: vectorsData,
};
res = await milvusClient.dataManager.insert(params);
console.log("--- insert ----", res);
await milvusClient.dataManager.flush({ collection_names: [COLLECTION_NAME] });
const result = await milvusClient.dataManager.search({
collection_name: COLLECTION_NAME,
Expand All @@ -45,6 +44,13 @@ const test = async () => {
vector_type: DataType.BinaryVector,
});
console.log("----search result-----,", result);
const queryRes = await milvusClient.dataManager.query({
collection_name: COLLECTION_NAME,
expr: `age == ${result.results[0].id}`,
output_fields: ["age", "vector_field"],
});
console.log("----query----", queryRes.data[0].vector_field);

await milvusClient.collectionManager.dropCollection({
collection_name: COLLECTION_NAME,
});
Expand Down
4 changes: 2 additions & 2 deletions example/Query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ const milvusClient = new MilvusClient(IP);
// when test_1 collection includes some data.
const query = async () => {
const res = await milvusClient.dataManager.query({
collection_name: "test_1",
expr: "id > 427621230836979095 and id < 427621230836979298",
collection_name: "test_binary",
expr: "id < 430543258556564053",
output_fields: ["id", "vector"],
});
console.log(res);
Expand Down
6 changes: 5 additions & 1 deletion milvus/Data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -541,7 +541,11 @@ export class Data extends Client {
const fieldsData = promise.fields_data.map((item, i) => {
if (item.field === "vectors") {
const key = item.vectors!.data;
const vectorValue = item.vectors![key]!.data;
const vectorValue =
key === "float_vector"
? item.vectors![key]!.data
: item.vectors![key]!.toJSON().data;

// if binary vector , need use dim / 8 to split vector data
const dim =
item.vectors?.data === "float_vector"
Expand Down
4 changes: 1 addition & 3 deletions milvus/types/Search.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,7 @@ export interface QueryRes {
float_vector?: {
data: number[];
};
binary_vector?: {
data: number[];
};
binary_vector?: Buffer;
};
scalars?: {
// long_data: {data: [stringID]}
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"name": "@zilliz/milvus2-sdk-node",
"author": "[email protected]",
"version": "1.0.20",
"milvusVersion": "v2.0.0",
"version": "1.1.0",
"milvusVersion": "v2.0.0-pre-ga",
"main": "dist/milvus",
"files": [
"dist"
Expand Down