Skip to content

Commit 4bae96f

Browse files
authored
Merge pull request #15 from nameczz/dev
Fix binary vector when query data and disable multiple vector fields when create collection
2 parents 41e0d45 + 2ffffd8 commit 4bae96f

File tree

8 files changed

+79
-27
lines changed

8 files changed

+79
-27
lines changed

.github/workflows/release.yml

+3
Original file line numberDiff line numberDiff line change
@@ -27,5 +27,8 @@ jobs:
2727
- name: Docker tag
2828
run: docker tag zilliz/attu:${GITHUB_REF#refs/tags/} zilliz/attu:latest
2929

30+
- name: Docker Push version
31+
run: docker push zilliz/attu:${GITHUB_REF#refs/tags/}
32+
3033
- name: Docker Push lastest
3134
run: docker push zilliz/attu

.gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ node_modules
99

1010
# testing
1111
/clientcoverage
12-
/client/vectors.csv
12+
**/vectors.csv
1313

1414
# production
1515

client/src/pages/collections/Constants.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export const VECTOR_FIELDS_OPTIONS: KeyValuePair[] = [
1313
];
1414

1515
export const ALL_OPTIONS: KeyValuePair[] = [
16-
...VECTOR_FIELDS_OPTIONS,
16+
// ...VECTOR_FIELDS_OPTIONS,
1717
{
1818
label: 'Int8',
1919
value: DataTypeEnum.Int8,

client/src/plugins/search/VectorSearch.tsx

+25-19
Original file line numberDiff line numberDiff line change
@@ -123,21 +123,20 @@ const VectorSearch = () => {
123123
*/
124124
return searchResult && searchResult.length > 0
125125
? Object.keys(searchResult[0])
126-
.filter(item => {
127-
// if primary key field name is id, don't filter it
128-
const invalidItems =
129-
primaryKeyField === 'id' ? ['score'] : ['id', 'score'];
130-
return !invalidItems.includes(item);
131-
})
132-
.map(key => ({
133-
id: key,
134-
align: 'left',
135-
disablePadding: false,
136-
label: key,
137-
}))
126+
.filter(item => {
127+
// if primary key field name is id, don't filter it
128+
const invalidItems =
129+
primaryKeyField === 'id' ? ['score'] : ['id', 'score'];
130+
return !invalidItems.includes(item);
131+
})
132+
.map(key => ({
133+
id: key,
134+
align: 'left',
135+
disablePadding: false,
136+
label: key,
137+
}))
138138
: [];
139139
}, [searchResult, primaryKeyField]);
140-
141140
const {
142141
metricType,
143142
indexType,
@@ -157,7 +156,6 @@ const VectorSearch = () => {
157156
index?._metricType || DEFAULT_METRIC_VALUE_MAP[embeddingType];
158157
const indexParams = index?._indexParameterPairs || [];
159158
const dim = selectedFieldInfo?.dimension || 0;
160-
161159
return {
162160
metricType: metric,
163161
indexType: index?._indexType || getDefaultIndexType(embeddingType),
@@ -187,10 +185,15 @@ const VectorSearch = () => {
187185
if (vectors === '' || selectedFieldDimension === 0) {
188186
return true;
189187
}
188+
const dim =
189+
fieldType === DataTypeEnum.BinaryVector
190+
? selectedFieldDimension / 8
191+
: selectedFieldDimension;
192+
console.log(fieldType);
190193
const value = parseValue(vectors);
191194
const isArray = Array.isArray(value);
192-
return isArray && value.length === selectedFieldDimension;
193-
}, [vectors, selectedFieldDimension]);
195+
return isArray && value.length === dim;
196+
}, [vectors, selectedFieldDimension, fieldType]);
194197

195198
const searchDisabled = useMemo(() => {
196199
/**
@@ -374,7 +377,10 @@ const VectorSearch = () => {
374377
{!vectorValueValid && (
375378
<Typography variant="caption" className={classes.error}>
376379
{searchTrans('vectorValueWarning', {
377-
dimension: selectedFieldDimension,
380+
dimension:
381+
fieldType === DataTypeEnum.BinaryVector
382+
? selectedFieldDimension / 8
383+
: selectedFieldDimension,
378384
})}
379385
</Typography>
380386
)}
@@ -421,8 +427,8 @@ const VectorSearch = () => {
421427
metricType={metricType!}
422428
embeddingType={
423429
embeddingType as
424-
| DataTypeEnum.BinaryVector
425-
| DataTypeEnum.FloatVector
430+
| DataTypeEnum.BinaryVector
431+
| DataTypeEnum.FloatVector
426432
}
427433
indexType={indexType}
428434
indexParams={indexParams!}

express/generate-csv.ts

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import { createObjectCsvWriter as createCsvWriter } from 'csv-writer';
2+
3+
// use to test vector insert
4+
const csvWriter = createCsvWriter({
5+
path: './vectors.csv',
6+
header: [{ id: 'vector', title: 'vector' }],
7+
});
8+
9+
const records = [];
10+
11+
const generateVector = (dimension: number) => {
12+
let index = 0;
13+
const vectors = [];
14+
while (index < dimension) {
15+
vectors.push(1 + Math.random());
16+
index++;
17+
}
18+
return JSON.stringify(vectors);
19+
};
20+
21+
while (records.length < 50000) {
22+
const value = generateVector(8);
23+
records.push({ vector: value });
24+
}
25+
26+
csvWriter
27+
.writeRecords(records) // returns a promise
28+
.then(() => {
29+
console.log('...Done');
30+
});

express/package.json

+3-2
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,14 @@
1212
"url": "https://github.com/zilliztech/attu"
1313
},
1414
"dependencies": {
15-
"@zilliz/milvus2-sdk-node": "^1.0.19",
15+
"@zilliz/milvus2-sdk-node": "^1.1.0",
1616
"chalk": "^4.1.2",
1717
"class-sanitizer": "^1.0.1",
1818
"class-transformer": "^0.4.0",
1919
"class-validator": "^0.13.1",
2020
"cors": "^2.8.5",
2121
"cross-env": "^7.0.3",
22+
"csv-writer": "^1.6.0",
2223
"express": "^4.17.1",
2324
"glob": "^7.2.0",
2425
"helmet": "^4.6.0",
@@ -137,4 +138,4 @@
137138
]
138139
}
139140
}
140-
}
141+
}

express/src/middlewares/index.ts

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ export const ReqHeaderMiddleware = (
1414
// all ape requests need set milvus address in header.
1515
// server will set activeaddress in milvus service.
1616
const milvusAddress = (req.headers[MILVUS_ADDRESS] as string) || '';
17+
1718
// only api request has MILVUS_ADDRESS.
1819
// When client run in express, we dont need static files like: xx.js run this logic.
1920
// Otherwise will cause 401 error.

express/yarn.lock

+15-4
Original file line numberDiff line numberDiff line change
@@ -1137,15 +1137,16 @@
11371137
dependencies:
11381138
"@types/yargs-parser" "*"
11391139

1140-
"@zilliz/milvus2-sdk-node@^1.0.19":
1141-
version "1.0.19"
1142-
resolved "https://registry.yarnpkg.com/@zilliz/milvus2-sdk-node/-/milvus2-sdk-node-1.0.19.tgz#966e68a2d88e62ba475a138b382fb71209670a2e"
1143-
integrity sha512-LMRRM+vU+AiB3ETUAzIgiFxVZJJ63vyuEP7cZevz4tQPXUW1tN63MVCWFVikQKx3QNE+ikArnoQIGJc0I9+kEA==
1140+
"@zilliz/milvus2-sdk-node@^1.1.0":
1141+
version "1.1.0"
1142+
resolved "https://registry.yarnpkg.com/@zilliz/milvus2-sdk-node/-/milvus2-sdk-node-1.1.0.tgz#0fc8c0b630bb29056363f86a86e6cc470e5ac63a"
1143+
integrity sha512-yVfGbJ+qOttUAb/KOxFmj8Pn4tGoSgWcR7xaN3P2LGX8czo1gzywJVqYgE0H6J8xA3B48hUYQ3dA8ie5LbTtgQ==
11441144
dependencies:
11451145
"@grpc/grpc-js" "^1.2.12"
11461146
"@grpc/proto-loader" "^0.6.0"
11471147
"@microsoft/api-documenter" "^7.13.39"
11481148
"@microsoft/api-extractor" "^7.18.5"
1149+
json-schema "^0.4.0"
11491150
protobufjs "^6.11.2"
11501151

11511152
abab@^2.0.3, abab@^2.0.5:
@@ -2005,6 +2006,11 @@ cssstyle@^2.3.0:
20052006
dependencies:
20062007
cssom "~0.3.6"
20072008

2009+
csv-writer@^1.6.0:
2010+
version "1.6.0"
2011+
resolved "https://registry.yarnpkg.com/csv-writer/-/csv-writer-1.6.0.tgz#d0cea44b6b4d7d3baa2ecc6f3f7209233514bcf9"
2012+
integrity sha512-NOx7YDFWEsM/fTRAJjRpPp8t+MKRVvniAg9wQlUKx20MFrPs73WLJhFf5iteqrxNYnsy924K3Iroh3yNHeYd2g==
2013+
20082014
data-urls@^2.0.0:
20092015
version "2.0.0"
20102016
resolved "https://registry.yarnpkg.com/data-urls/-/data-urls-2.0.0.tgz#156485a72963a970f5d5821aaf642bef2bf2db9b"
@@ -3637,6 +3643,11 @@ json-schema-traverse@^0.4.1:
36373643
resolved "https://registry.yarnpkg.com/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz#69f6a87d9513ab8bb8fe63bdb0979c448e684660"
36383644
integrity sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==
36393645

3646+
json-schema@^0.4.0:
3647+
version "0.4.0"
3648+
resolved "https://registry.yarnpkg.com/json-schema/-/json-schema-0.4.0.tgz#f7de4cf6efab838ebaeb3236474cbba5a1930ab5"
3649+
integrity sha512-es94M3nTIfsEPisRafak+HDLfHXnKBhV3vU5eqPcS3flIWqcxJWgXHXiey3YrpaNsanY5ei1VoYEbOzijuq9BA==
3650+
36403651
json-stringify-safe@^5.0.1:
36413652
version "5.0.1"
36423653
resolved "https://registry.yarnpkg.com/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz#1296a2d58fd45f19a0f6ce01d65701e2c735b6eb"

0 commit comments

Comments
 (0)