55 "fmt"
66 "os"
77 "os/signal"
8- "strings"
98 "syscall"
109
1110 "github.com/pinecone-io/go-pinecone/v3/pinecone"
@@ -29,22 +28,13 @@ type MigrateFromPineconeCmd struct {
2928 targetTLS bool
3029}
3130
32- func stripScheme (input string ) string {
33- if idx := strings .Index (input , "://" ); idx != - 1 {
34- return input [idx + 3 :]
35- }
36- return input
37- }
38-
3931func (r * MigrateFromPineconeCmd ) Parse () error {
4032 var err error
4133 r .targetHost , r .targetPort , r .targetTLS , err = parseQdrantUrl (r .Qdrant .Url )
4234 if err != nil {
4335 return fmt .Errorf ("failed to parse target URL: %w" , err )
4436 }
4537
46- r .Pinecone .Host = stripScheme (r .Pinecone .Host )
47-
4838 return nil
4939}
5040
@@ -88,7 +78,7 @@ func (r *MigrateFromPineconeCmd) Run(globals *Globals) error {
8878 return fmt .Errorf ("error preparing target collection: %w" , err )
8979 }
9080
91- displayMigrationStart ("pinecone" , r .Pinecone .Host , r .Qdrant .Collection )
81+ displayMigrationStart ("pinecone" , r .Pinecone .IndexHost , r .Qdrant .Collection )
9282
9383 err = r .migrateData (ctx , sourceIndexConn , targetClient , sourcePointCount )
9484 if err != nil {
@@ -110,14 +100,15 @@ func (r *MigrateFromPineconeCmd) Run(globals *Globals) error {
110100
111101func (r * MigrateFromPineconeCmd ) connectToPinecone () (* pinecone.Client , * pinecone.IndexConnection , error ) {
112102 client , err := pinecone .NewClient (pinecone.NewClientParams {
103+ Host : r .Pinecone .ServiceHost ,
113104 ApiKey : r .Pinecone .APIKey ,
114105 })
115106 if err != nil {
116107 return nil , nil , fmt .Errorf ("failed to create Pinecone client: %w" , err )
117108 }
118109
119110 indexConn , err := client .Index (pinecone.NewIndexConnParams {
120- Host : r .Pinecone .Host ,
111+ Host : r .Pinecone .IndexHost ,
121112 Namespace : r .Pinecone .Namespace ,
122113 })
123114 if err != nil {
@@ -158,14 +149,14 @@ func (r *MigrateFromPineconeCmd) prepareTargetCollection(ctx context.Context, so
158149
159150 var foundIndex * pinecone.Index
160151 for i := range indexes {
161- if indexes [i ].Host == r .Pinecone .Host {
152+ if indexes [i ].Name == r .Pinecone .IndexName {
162153 foundIndex = indexes [i ]
163154 break
164155 }
165156 }
166157
167158 if foundIndex == nil {
168- return fmt .Errorf ("index %q not found in Pinecone" , r .Pinecone .Host )
159+ return fmt .Errorf ("index %q not found in Pinecone" , r .Pinecone .IndexName )
169160 }
170161
171162 distanceMapping := map [pinecone.IndexMetric ]qdrant.Distance {
@@ -213,7 +204,7 @@ func (r *MigrateFromPineconeCmd) migrateData(ctx context.Context, sourceIndexCon
213204 offsetCount := uint64 (0 )
214205
215206 if ! r .Migration .Restart {
216- id , offsetStored , err := commons .GetStartOffset (ctx , r .Migration .OffsetsCollection , targetClient , r .Pinecone .Host )
207+ id , offsetStored , err := commons .GetStartOffset (ctx , r .Migration .OffsetsCollection , targetClient , r .Pinecone .IndexHost )
217208 if err != nil {
218209 return fmt .Errorf ("failed to get start offset: %w" , err )
219210 }
@@ -239,7 +230,7 @@ func (r *MigrateFromPineconeCmd) migrateData(ctx context.Context, sourceIndexCon
239230 }
240231
241232 if len (listRes .VectorIds ) < 1 {
242- return fmt . Errorf ( "pinecone.ListVectors returned no IDs" )
233+ break
243234 }
244235
245236 ids := make ([]string , 0 , len (listRes .VectorIds ))
@@ -298,7 +289,7 @@ func (r *MigrateFromPineconeCmd) migrateData(ctx context.Context, sourceIndexCon
298289 if listRes .NextPaginationToken != nil {
299290 offsetCount += uint64 (len (targetPoints ))
300291 offsetId = qdrant .NewID (* listRes .NextPaginationToken )
301- err = commons .StoreStartOffset (ctx , r .Migration .OffsetsCollection , targetClient , r .Pinecone .Host , offsetId , offsetCount )
292+ err = commons .StoreStartOffset (ctx , r .Migration .OffsetsCollection , targetClient , r .Pinecone .IndexHost , offsetId , offsetCount )
302293 if err != nil {
303294 return fmt .Errorf ("failed to store offset: %w" , err )
304295 }
0 commit comments