@@ -16,11 +16,11 @@ import (
16
16
)
17
17
18
18
type Demo struct {
19
- client * tcvectordb.RpcClient
19
+ client * tcvectordb.Client
20
20
}
21
21
22
22
func NewDemo (url , username , key string ) (* Demo , error ) {
23
- cli , err := tcvectordb .NewRpcClient (url , username , key , & tcvectordb.ClientOption {
23
+ cli , err := tcvectordb .NewClient (url , username , key , & tcvectordb.ClientOption {
24
24
ReadConsistency : tcvectordb .StrongConsistency })
25
25
if err != nil {
26
26
return nil , err
@@ -109,8 +109,14 @@ func (d *Demo) UploadFile(ctx context.Context, database, collection, localFilePa
109
109
"sectionNum" : "section_num" ,
110
110
},
111
111
MetaData : map [string ]interface {}{
112
- "testStr" : "v1" ,
113
- "testInt" : 1024 ,
112
+ "testStr" : "v1" ,
113
+ "testInt" : 1024 ,
114
+ "testDouble" : 0.1 ,
115
+ "testArray" : []string {"one" , "two" },
116
+ "testJson" : map [string ]interface {}{
117
+ "a" : 1 ,
118
+ "b" : "str" ,
119
+ },
114
120
},
115
121
}
116
122
@@ -125,6 +131,22 @@ func (d *Demo) UploadFile(ctx context.Context, database, collection, localFilePa
125
131
126
132
func (d * Demo ) QueryData (ctx context.Context , database , collection , filename string ) error {
127
133
time .Sleep (15 * time .Second )
134
+ log .Println ("------------------------------ Query file details after waiting 15s to parse file ------------------------------" )
135
+ //limit := int64(2)
136
+ fileDetialRes , err := d .client .QueryFileDetails (ctx , database , collection , & tcvectordb.QueryFileDetailsParams {
137
+ FileNames : []string {filename },
138
+ // Filter: tcvectordb.NewFilter(`_indexed_status = \"Ready\"`),
139
+ // Limit: &limit,
140
+ // Offset: 0,
141
+ // OutputFields: []string{"id", "_indexed_status", "_user_metadata"},
142
+ })
143
+ if err != nil {
144
+ return err
145
+ }
146
+ for _ , doc := range fileDetialRes .Documents {
147
+ log .Printf ("File detail: %+v" , doc )
148
+ }
149
+
128
150
log .Println ("------------------------------ Query after waiting 15s to parse file ------------------------------" )
129
151
130
152
result , err := d .client .Query (ctx , database , collection , []string {}, & tcvectordb.QueryDocumentParams {
@@ -253,21 +275,23 @@ func printErr(err error) {
253
275
}
254
276
255
277
func main () {
256
- database := "go-sdk-demo -db"
257
- collectionName := "go-sdk-demo-col-test4 "
278
+ database := "test -db"
279
+ collectionName := "test-coll "
258
280
259
281
_ , filePath , _ , _ := runtime .Caller (0 )
260
- localFilePath := path .Join (path .Dir (filePath ), "../demo_files/tcvdb.pdf " )
282
+ localFilePath := path .Join (path .Dir (filePath ), "../demo_files/tcvdb.md " )
261
283
filename := filepath .Base (localFilePath )
262
284
263
285
ctx := context .Background ()
264
286
testVdb , err := NewDemo ("vdb http url or ip and port" , "vdb username" , "key get from web console" )
287
+ printErr (err )
288
+ err = testVdb .DeleteAndDrop (ctx , database , collectionName )
289
+ printErr (err )
265
290
err = testVdb .CreateDBAndCollection (ctx , database , collectionName )
266
291
printErr (err )
267
292
err = testVdb .UploadFile (ctx , database , collectionName , localFilePath )
268
293
printErr (err )
269
294
err = testVdb .QueryData (ctx , database , collectionName , filename )
270
295
printErr (err )
271
- err = testVdb .DeleteAndDrop (ctx , database , collectionName )
272
- printErr (err )
296
+
273
297
}
0 commit comments