native-vector-store 0.2.0 → 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/README.md +239 -9
  2. package/binding.gyp +3 -2
  3. package/docs/PERFORMANCE_CASE_STUDY.md +130 -0
  4. package/docs/PREBUILDS.md +69 -0
  5. package/docs/VectorStore.html +180 -0
  6. package/docs/VectorStoreWrapper.html +1356 -0
  7. package/docs/fonts/OpenSans-Bold-webfont.eot +0 -0
  8. package/docs/fonts/OpenSans-Bold-webfont.svg +1830 -0
  9. package/docs/fonts/OpenSans-Bold-webfont.woff +0 -0
  10. package/docs/fonts/OpenSans-BoldItalic-webfont.eot +0 -0
  11. package/docs/fonts/OpenSans-BoldItalic-webfont.svg +1830 -0
  12. package/docs/fonts/OpenSans-BoldItalic-webfont.woff +0 -0
  13. package/docs/fonts/OpenSans-Italic-webfont.eot +0 -0
  14. package/docs/fonts/OpenSans-Italic-webfont.svg +1830 -0
  15. package/docs/fonts/OpenSans-Italic-webfont.woff +0 -0
  16. package/docs/fonts/OpenSans-Light-webfont.eot +0 -0
  17. package/docs/fonts/OpenSans-Light-webfont.svg +1831 -0
  18. package/docs/fonts/OpenSans-Light-webfont.woff +0 -0
  19. package/docs/fonts/OpenSans-LightItalic-webfont.eot +0 -0
  20. package/docs/fonts/OpenSans-LightItalic-webfont.svg +1835 -0
  21. package/docs/fonts/OpenSans-LightItalic-webfont.woff +0 -0
  22. package/docs/fonts/OpenSans-Regular-webfont.eot +0 -0
  23. package/docs/fonts/OpenSans-Regular-webfont.svg +1831 -0
  24. package/docs/fonts/OpenSans-Regular-webfont.woff +0 -0
  25. package/docs/global.html +561 -0
  26. package/docs/index.html +577 -0
  27. package/docs/scripts/linenumber.js +25 -0
  28. package/docs/scripts/prettify/Apache-License-2.0.txt +202 -0
  29. package/docs/scripts/prettify/lang-css.js +2 -0
  30. package/docs/scripts/prettify/prettify.js +28 -0
  31. package/docs/styles/jsdoc-default.css +358 -0
  32. package/docs/styles/prettify-jsdoc.css +111 -0
  33. package/docs/styles/prettify-tomorrow.css +132 -0
  34. package/index.js +162 -0
  35. package/package.json +7 -3
  36. package/prebuilds/darwin-arm64/native-vector-store.node +0 -0
  37. package/prebuilds/darwin-x64/native-vector-store.node +0 -0
  38. package/prebuilds/linux-arm64/native-vector-store.node +0 -0
  39. package/prebuilds/linux-x64/native-vector-store.node +0 -0
  40. package/prebuilds/linux-x64-musl/napi-v9/native-vector-store.node +0 -0
  41. package/prebuilds/linux-x64-musl/native-vector-store.node +0 -0
  42. package/prebuilds/win32-x64/native-vector-store.node +0 -0
  43. package/src/Makefile +4 -4
  44. /package/{src → deps/atomic_queue}/atomic_queue.h +0 -0
  45. /package/{src → deps/atomic_queue}/defs.h +0 -0
  46. /package/deps/{simdjson.cpp → simdjson/simdjson.cpp} +0 -0
  47. /package/deps/{simdjson.h → simdjson/simdjson.h} +0 -0
@@ -0,0 +1,1356 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <title>JSDoc: Class: VectorStoreWrapper</title>
6
+
7
+ <script src="scripts/prettify/prettify.js"> </script>
8
+ <script src="scripts/prettify/lang-css.js"> </script>
9
+ <!--[if lt IE 9]>
10
+ <script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
11
+ <![endif]-->
12
+ <link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
13
+ <link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
14
+ </head>
15
+
16
+ <body>
17
+
18
+ <div id="main">
19
+
20
+ <h1 class="page-title">Class: VectorStoreWrapper</h1>
21
+
22
+
23
+
24
+
25
+
26
+
27
+ <section>
28
+
29
+ <header>
30
+
31
+ <h2><span class="attribs"><span class="type-signature"></span></span>VectorStoreWrapper<span class="signature">(dimensions)</span><span class="type-signature"></span></h2>
32
+
33
+
34
+ </header>
35
+
36
+ <article>
37
+ <div class="container-overview">
38
+
39
+
40
+
41
+
42
+
43
+
44
+ <h4 class="name" id="VectorStoreWrapper"><span class="type-signature"></span>new VectorStoreWrapper<span class="signature">(dimensions)</span><span class="type-signature"></span></h4>
45
+
46
+
47
+
48
+
49
+
50
+
51
+ <div class="description">
52
+ <p>Creates a new VectorStore instance</p>
53
+ </div>
54
+
55
+
56
+
57
+
58
+
59
+
60
+
61
+
62
+
63
+ <h5>Parameters:</h5>
64
+
65
+
66
+ <table class="params">
67
+ <thead>
68
+ <tr>
69
+
70
+ <th>Name</th>
71
+
72
+
73
+ <th>Type</th>
74
+
75
+
76
+
77
+
78
+
79
+ <th class="last">Description</th>
80
+ </tr>
81
+ </thead>
82
+
83
+ <tbody>
84
+
85
+
86
+ <tr>
87
+
88
+ <td class="name"><code>dimensions</code></td>
89
+
90
+
91
+ <td class="type">
92
+
93
+
94
+ <span class="param-type">number</span>
95
+
96
+
97
+
98
+ </td>
99
+
100
+
101
+
102
+
103
+
104
+ <td class="description last"><p>The dimensionality of embedding vectors (e.g., 1536 for OpenAI embeddings)</p></td>
105
+ </tr>
106
+
107
+
108
+ </tbody>
109
+ </table>
110
+
111
+
112
+
113
+
114
+
115
+
116
+ <dl class="details">
117
+
118
+
119
+
120
+
121
+
122
+
123
+
124
+
125
+
126
+
127
+
128
+
129
+
130
+
131
+
132
+
133
+
134
+
135
+
136
+
137
+
138
+
139
+
140
+
141
+
142
+
143
+
144
+
145
+
146
+
147
+
148
+
149
+ </dl>
150
+
151
+
152
+
153
+
154
+
155
+
156
+
157
+
158
+
159
+
160
+
161
+
162
+
163
+ <h5>Throws:</h5>
164
+
165
+
166
+
167
+ <dl>
168
+ <dt>
169
+ <div class="param-desc">
170
+ <p>If dimensions is not a positive integer</p>
171
+ </div>
172
+ </dt>
173
+ <dd></dd>
174
+ <dt>
175
+ <dl>
176
+ <dt>
177
+ Type
178
+ </dt>
179
+ <dd>
180
+
181
+ <span class="param-type">TypeError</span>
182
+
183
+
184
+ </dd>
185
+ </dl>
186
+ </dt>
187
+ <dd></dd>
188
+ </dl>
189
+
190
+
191
+
192
+
193
+
194
+
195
+
196
+
197
+
198
+
199
+
200
+ </div>
201
+
202
+
203
+
204
+
205
+
206
+
207
+
208
+
209
+
210
+
211
+
212
+
213
+
214
+
215
+
216
+
217
+ <h3 class="subsection-title">Methods</h3>
218
+
219
+
220
+
221
+
222
+
223
+
224
+
225
+ <h4 class="name" id="addDocument"><span class="type-signature"></span>addDocument<span class="signature">(doc)</span><span class="type-signature"> &rarr; {void}</span></h4>
226
+
227
+
228
+
229
+
230
+
231
+
232
+ <div class="description">
233
+ <p>Add a single document to the store. Only works before finalization.</p>
234
+ </div>
235
+
236
+
237
+
238
+
239
+
240
+
241
+
242
+
243
+
244
+ <h5>Parameters:</h5>
245
+
246
+
247
+ <table class="params">
248
+ <thead>
249
+ <tr>
250
+
251
+ <th>Name</th>
252
+
253
+
254
+ <th>Type</th>
255
+
256
+
257
+
258
+
259
+
260
+ <th class="last">Description</th>
261
+ </tr>
262
+ </thead>
263
+
264
+ <tbody>
265
+
266
+
267
+ <tr>
268
+
269
+ <td class="name"><code>doc</code></td>
270
+
271
+
272
+ <td class="type">
273
+
274
+
275
+ <span class="param-type"><a href="global.html#Document">Document</a></span>
276
+
277
+
278
+
279
+ </td>
280
+
281
+
282
+
283
+
284
+
285
+ <td class="description last"><p>Document object with embedding in metadata</p></td>
286
+ </tr>
287
+
288
+
289
+ </tbody>
290
+ </table>
291
+
292
+
293
+
294
+
295
+
296
+
297
+ <dl class="details">
298
+
299
+
300
+
301
+
302
+
303
+
304
+
305
+
306
+
307
+
308
+
309
+
310
+
311
+
312
+
313
+
314
+
315
+
316
+
317
+
318
+
319
+
320
+
321
+
322
+
323
+
324
+
325
+
326
+
327
+
328
+
329
+
330
+ </dl>
331
+
332
+
333
+
334
+
335
+
336
+
337
+
338
+
339
+
340
+
341
+
342
+
343
+
344
+ <h5>Throws:</h5>
345
+
346
+
347
+
348
+ <dl>
349
+ <dt>
350
+ <div class="param-desc">
351
+ <p>If called after finalization or document format is invalid</p>
352
+ </div>
353
+ </dt>
354
+ <dd></dd>
355
+ <dt>
356
+ <dl>
357
+ <dt>
358
+ Type
359
+ </dt>
360
+ <dd>
361
+
362
+ <span class="param-type">Error</span>
363
+
364
+
365
+ </dd>
366
+ </dl>
367
+ </dt>
368
+ <dd></dd>
369
+ </dl>
370
+
371
+
372
+
373
+
374
+
375
+ <h5>Returns:</h5>
376
+
377
+
378
+
379
+
380
+ <dl>
381
+ <dt>
382
+ Type
383
+ </dt>
384
+ <dd>
385
+
386
+ <span class="param-type">void</span>
387
+
388
+
389
+ </dd>
390
+ </dl>
391
+
392
+
393
+
394
+
395
+
396
+
397
+ <h5>Example</h5>
398
+
399
+ <pre class="prettyprint"><code>store.addDocument({
400
+ id: 'doc-1',
401
+ text: 'Sample document',
402
+ metadata: {
403
+ embedding: new Array(1536).fill(0).map(() => Math.random())
404
+ }
405
+ });</code></pre>
406
+
407
+
408
+
409
+
410
+
411
+
412
+
413
+
414
+
415
+ <h4 class="name" id="finalize"><span class="type-signature"></span>finalize<span class="signature">()</span><span class="type-signature"> &rarr; {void}</span></h4>
416
+
417
+
418
+
419
+
420
+
421
+
422
+ <div class="description">
423
+ <p>Finalize the store: normalize all embeddings and switch to serving mode.
424
+ After calling this, no more documents can be added but searches become available.
425
+ This is automatically called by loadDir().</p>
426
+ </div>
427
+
428
+
429
+
430
+
431
+
432
+
433
+
434
+
435
+
436
+
437
+
438
+
439
+
440
+ <dl class="details">
441
+
442
+
443
+
444
+
445
+
446
+
447
+
448
+
449
+
450
+
451
+
452
+
453
+
454
+
455
+
456
+
457
+
458
+
459
+
460
+
461
+
462
+
463
+
464
+
465
+
466
+
467
+
468
+
469
+
470
+
471
+
472
+
473
+ </dl>
474
+
475
+
476
+
477
+
478
+
479
+
480
+
481
+
482
+
483
+
484
+
485
+
486
+
487
+
488
+
489
+ <h5>Returns:</h5>
490
+
491
+
492
+
493
+
494
+ <dl>
495
+ <dt>
496
+ Type
497
+ </dt>
498
+ <dd>
499
+
500
+ <span class="param-type">void</span>
501
+
502
+
503
+ </dd>
504
+ </dl>
505
+
506
+
507
+
508
+
509
+
510
+
511
+ <h5>Example</h5>
512
+
513
+ <pre class="prettyprint"><code>// Manual finalization after adding documents
514
+ store.addDocument(doc1);
515
+ store.addDocument(doc2);
516
+ store.finalize(); // Must call before searching</code></pre>
517
+
518
+
519
+
520
+
521
+
522
+
523
+
524
+
525
+
526
+ <h4 class="name" id="isFinalized"><span class="type-signature"></span>isFinalized<span class="signature">()</span><span class="type-signature"> &rarr; {boolean}</span></h4>
527
+
528
+
529
+
530
+
531
+
532
+
533
+ <div class="description">
534
+ <p>Check if the store has been finalized and is ready for searching.</p>
535
+ </div>
536
+
537
+
538
+
539
+
540
+
541
+
542
+
543
+
544
+
545
+
546
+
547
+
548
+
549
+ <dl class="details">
550
+
551
+
552
+
553
+
554
+
555
+
556
+
557
+
558
+
559
+
560
+
561
+
562
+
563
+
564
+
565
+
566
+
567
+
568
+
569
+
570
+
571
+
572
+
573
+
574
+
575
+
576
+
577
+
578
+
579
+
580
+
581
+
582
+ </dl>
583
+
584
+
585
+
586
+
587
+
588
+
589
+
590
+
591
+
592
+
593
+
594
+
595
+
596
+
597
+
598
+ <h5>Returns:</h5>
599
+
600
+
601
+ <div class="param-desc">
602
+ <p>True if finalized, false otherwise</p>
603
+ </div>
604
+
605
+
606
+
607
+ <dl>
608
+ <dt>
609
+ Type
610
+ </dt>
611
+ <dd>
612
+
613
+ <span class="param-type">boolean</span>
614
+
615
+
616
+ </dd>
617
+ </dl>
618
+
619
+
620
+
621
+
622
+
623
+
624
+ <h5>Example</h5>
625
+
626
+ <pre class="prettyprint"><code>if (store.isFinalized()) {
627
+ const results = store.search(query, 10);
628
+ }</code></pre>
629
+
630
+
631
+
632
+
633
+
634
+
635
+
636
+
637
+
638
+ <h4 class="name" id="loadDir"><span class="type-signature"></span>loadDir<span class="signature">(path)</span><span class="type-signature"> &rarr; {void}</span></h4>
639
+
640
+
641
+
642
+
643
+
644
+
645
+ <div class="description">
646
+ <p>Load all JSON documents from a directory and automatically finalize the store.
647
+ Documents should contain embedding vectors in their metadata field.
648
+ Supports both single documents and arrays of documents per file.</p>
649
+ </div>
650
+
651
+
652
+
653
+
654
+
655
+
656
+
657
+
658
+
659
+ <h5>Parameters:</h5>
660
+
661
+
662
+ <table class="params">
663
+ <thead>
664
+ <tr>
665
+
666
+ <th>Name</th>
667
+
668
+
669
+ <th>Type</th>
670
+
671
+
672
+
673
+
674
+
675
+ <th class="last">Description</th>
676
+ </tr>
677
+ </thead>
678
+
679
+ <tbody>
680
+
681
+
682
+ <tr>
683
+
684
+ <td class="name"><code>path</code></td>
685
+
686
+
687
+ <td class="type">
688
+
689
+
690
+ <span class="param-type">string</span>
691
+
692
+
693
+
694
+ </td>
695
+
696
+
697
+
698
+
699
+
700
+ <td class="description last"><p>Absolute or relative path to directory containing JSON files</p></td>
701
+ </tr>
702
+
703
+
704
+ </tbody>
705
+ </table>
706
+
707
+
708
+
709
+
710
+
711
+
712
+ <dl class="details">
713
+
714
+
715
+
716
+
717
+
718
+
719
+
720
+
721
+
722
+
723
+
724
+
725
+
726
+
727
+
728
+
729
+
730
+
731
+
732
+
733
+
734
+
735
+
736
+
737
+
738
+
739
+
740
+
741
+
742
+
743
+
744
+
745
+ </dl>
746
+
747
+
748
+
749
+
750
+
751
+
752
+
753
+
754
+
755
+
756
+
757
+
758
+
759
+ <h5>Throws:</h5>
760
+
761
+
762
+
763
+ <dl>
764
+ <dt>
765
+ <div class="param-desc">
766
+ <p>If directory doesn't exist or contains invalid JSON</p>
767
+ </div>
768
+ </dt>
769
+ <dd></dd>
770
+ <dt>
771
+ <dl>
772
+ <dt>
773
+ Type
774
+ </dt>
775
+ <dd>
776
+
777
+ <span class="param-type">Error</span>
778
+
779
+
780
+ </dd>
781
+ </dl>
782
+ </dt>
783
+ <dd></dd>
784
+ </dl>
785
+
786
+
787
+
788
+
789
+
790
+ <h5>Returns:</h5>
791
+
792
+
793
+
794
+
795
+ <dl>
796
+ <dt>
797
+ Type
798
+ </dt>
799
+ <dd>
800
+
801
+ <span class="param-type">void</span>
802
+
803
+
804
+ </dd>
805
+ </dl>
806
+
807
+
808
+
809
+
810
+
811
+
812
+ <h5>Examples</h5>
813
+
814
+ <pre class="prettyprint"><code>// Load documents from a directory
815
+ store.loadDir('./knowledge-base');
816
+ // Store is automatically finalized and ready for searches</code></pre>
817
+
818
+ <pre class="prettyprint"><code>// Document format in JSON files
819
+ {
820
+ "id": "doc-123",
821
+ "text": "Document content...",
822
+ "metadata": {
823
+ "embedding": [0.1, 0.2, ...], // Required: embedding vector
824
+ "category": "product" // Optional: additional metadata
825
+ }
826
+ }</code></pre>
827
+
828
+
829
+
830
+
831
+
832
+
833
+
834
+
835
+
836
+ <h4 class="name" id="normalize"><span class="type-signature"></span>normalize<span class="signature">()</span><span class="type-signature"> &rarr; {void}</span></h4>
837
+
838
+
839
+
840
+
841
+
842
+
843
+
844
+
845
+
846
+
847
+
848
+
849
+
850
+
851
+
852
+
853
+
854
+
855
+ <dl class="details">
856
+
857
+
858
+
859
+
860
+
861
+
862
+
863
+
864
+
865
+
866
+
867
+
868
+
869
+
870
+
871
+
872
+ <dt class="important tag-deprecated">Deprecated:</dt><dd><ul class="dummy"><li>Use finalize() instead</li></ul></dd>
873
+
874
+
875
+
876
+
877
+
878
+
879
+
880
+
881
+
882
+
883
+
884
+
885
+
886
+
887
+
888
+
889
+
890
+ </dl>
891
+
892
+
893
+
894
+
895
+
896
+
897
+
898
+
899
+
900
+
901
+
902
+
903
+
904
+
905
+
906
+ <h5>Returns:</h5>
907
+
908
+
909
+
910
+
911
+ <dl>
912
+ <dt>
913
+ Type
914
+ </dt>
915
+ <dd>
916
+
917
+ <span class="param-type">void</span>
918
+
919
+
920
+ </dd>
921
+ </dl>
922
+
923
+
924
+
925
+
926
+
927
+
928
+
929
+
930
+
931
+
932
+
933
+
934
+
935
+ <h4 class="name" id="search"><span class="type-signature"></span>search<span class="signature">(query, k, normalizeQuery<span class="signature-attributes">opt</span>)</span><span class="type-signature"> &rarr; {Array.&lt;<a href="global.html#SearchResult">SearchResult</a>>}</span></h4>
936
+
937
+
938
+
939
+
940
+
941
+
942
+ <div class="description">
943
+ <p>Search for the k most similar documents to a query embedding.
944
+ Uses SIMD-optimized cosine similarity for fast performance.</p>
945
+ </div>
946
+
947
+
948
+
949
+
950
+
951
+
952
+
953
+
954
+
955
+ <h5>Parameters:</h5>
956
+
957
+
958
+ <table class="params">
959
+ <thead>
960
+ <tr>
961
+
962
+ <th>Name</th>
963
+
964
+
965
+ <th>Type</th>
966
+
967
+
968
+ <th>Attributes</th>
969
+
970
+
971
+
972
+ <th>Default</th>
973
+
974
+
975
+ <th class="last">Description</th>
976
+ </tr>
977
+ </thead>
978
+
979
+ <tbody>
980
+
981
+
982
+ <tr>
983
+
984
+ <td class="name"><code>query</code></td>
985
+
986
+
987
+ <td class="type">
988
+
989
+
990
+ <span class="param-type">Float32Array</span>
991
+
992
+
993
+
994
+ </td>
995
+
996
+
997
+ <td class="attributes">
998
+
999
+
1000
+
1001
+
1002
+
1003
+ </td>
1004
+
1005
+
1006
+
1007
+ <td class="default">
1008
+
1009
+ </td>
1010
+
1011
+
1012
+ <td class="description last"><p>Query embedding vector (must match store dimensions)</p></td>
1013
+ </tr>
1014
+
1015
+
1016
+
1017
+ <tr>
1018
+
1019
+ <td class="name"><code>k</code></td>
1020
+
1021
+
1022
+ <td class="type">
1023
+
1024
+
1025
+ <span class="param-type">number</span>
1026
+
1027
+
1028
+
1029
+ </td>
1030
+
1031
+
1032
+ <td class="attributes">
1033
+
1034
+
1035
+
1036
+
1037
+
1038
+ </td>
1039
+
1040
+
1041
+
1042
+ <td class="default">
1043
+
1044
+ </td>
1045
+
1046
+
1047
+ <td class="description last"><p>Number of results to return (top-k nearest neighbors)</p></td>
1048
+ </tr>
1049
+
1050
+
1051
+
1052
+ <tr>
1053
+
1054
+ <td class="name"><code>normalizeQuery</code></td>
1055
+
1056
+
1057
+ <td class="type">
1058
+
1059
+
1060
+ <span class="param-type">boolean</span>
1061
+
1062
+
1063
+
1064
+ </td>
1065
+
1066
+
1067
+ <td class="attributes">
1068
+
1069
+ &lt;optional><br>
1070
+
1071
+
1072
+
1073
+
1074
+
1075
+ </td>
1076
+
1077
+
1078
+
1079
+ <td class="default">
1080
+
1081
+ true
1082
+
1083
+ </td>
1084
+
1085
+
1086
+ <td class="description last"><p>Whether to L2-normalize the query vector</p></td>
1087
+ </tr>
1088
+
1089
+
1090
+ </tbody>
1091
+ </table>
1092
+
1093
+
1094
+
1095
+
1096
+
1097
+
1098
+ <dl class="details">
1099
+
1100
+
1101
+
1102
+
1103
+
1104
+
1105
+
1106
+
1107
+
1108
+
1109
+
1110
+
1111
+
1112
+
1113
+
1114
+
1115
+
1116
+
1117
+
1118
+
1119
+
1120
+
1121
+
1122
+
1123
+
1124
+
1125
+
1126
+
1127
+
1128
+
1129
+
1130
+
1131
+ </dl>
1132
+
1133
+
1134
+
1135
+
1136
+
1137
+
1138
+
1139
+
1140
+
1141
+
1142
+
1143
+
1144
+
1145
+ <h5>Throws:</h5>
1146
+
1147
+
1148
+
1149
+ <dl>
1150
+ <dt>
1151
+ <div class="param-desc">
1152
+ <p>If store is not finalized or query dimensions don't match</p>
1153
+ </div>
1154
+ </dt>
1155
+ <dd></dd>
1156
+ <dt>
1157
+ <dl>
1158
+ <dt>
1159
+ Type
1160
+ </dt>
1161
+ <dd>
1162
+
1163
+ <span class="param-type">Error</span>
1164
+
1165
+
1166
+ </dd>
1167
+ </dl>
1168
+ </dt>
1169
+ <dd></dd>
1170
+ </dl>
1171
+
1172
+
1173
+
1174
+
1175
+
1176
+ <h5>Returns:</h5>
1177
+
1178
+
1179
+ <div class="param-desc">
1180
+ <p>Array of search results sorted by similarity (highest first)</p>
1181
+ </div>
1182
+
1183
+
1184
+
1185
+ <dl>
1186
+ <dt>
1187
+ Type
1188
+ </dt>
1189
+ <dd>
1190
+
1191
+ <span class="param-type">Array.&lt;<a href="global.html#SearchResult">SearchResult</a>></span>
1192
+
1193
+
1194
+ </dd>
1195
+ </dl>
1196
+
1197
+
1198
+
1199
+
1200
+
1201
+
1202
+ <h5>Examples</h5>
1203
+
1204
+ <pre class="prettyprint"><code>// Basic search
1205
+ const queryEmbedding = new Float32Array(1536);
1206
+ const results = store.search(queryEmbedding, 10);</code></pre>
1207
+
1208
+ <pre class="prettyprint"><code>// Search with pre-normalized query
1209
+ const normalized = normalizeVector(queryEmbedding);
1210
+ const results = store.search(normalized, 5, false);</code></pre>
1211
+
1212
+ <pre class="prettyprint"><code>// Filter results by score threshold
1213
+ const results = store.search(queryEmbedding, 20)
1214
+ .filter(r => r.score > 0.7);</code></pre>
1215
+
1216
+
1217
+
1218
+
1219
+
1220
+
1221
+
1222
+
1223
+
1224
+ <h4 class="name" id="size"><span class="type-signature"></span>size<span class="signature">()</span><span class="type-signature"> &rarr; {number}</span></h4>
1225
+
1226
+
1227
+
1228
+
1229
+
1230
+
1231
+ <div class="description">
1232
+ <p>Get the number of documents in the store.</p>
1233
+ </div>
1234
+
1235
+
1236
+
1237
+
1238
+
1239
+
1240
+
1241
+
1242
+
1243
+
1244
+
1245
+
1246
+
1247
+ <dl class="details">
1248
+
1249
+
1250
+
1251
+
1252
+
1253
+
1254
+
1255
+
1256
+
1257
+
1258
+
1259
+
1260
+
1261
+
1262
+
1263
+
1264
+
1265
+
1266
+
1267
+
1268
+
1269
+
1270
+
1271
+
1272
+
1273
+
1274
+
1275
+
1276
+
1277
+
1278
+
1279
+
1280
+ </dl>
1281
+
1282
+
1283
+
1284
+
1285
+
1286
+
1287
+
1288
+
1289
+
1290
+
1291
+
1292
+
1293
+
1294
+
1295
+
1296
+ <h5>Returns:</h5>
1297
+
1298
+
1299
+ <div class="param-desc">
1300
+ <p>Number of documents loaded</p>
1301
+ </div>
1302
+
1303
+
1304
+
1305
+ <dl>
1306
+ <dt>
1307
+ Type
1308
+ </dt>
1309
+ <dd>
1310
+
1311
+ <span class="param-type">number</span>
1312
+
1313
+
1314
+ </dd>
1315
+ </dl>
1316
+
1317
+
1318
+
1319
+
1320
+
1321
+
1322
+ <h5>Example</h5>
1323
+
1324
+ <pre class="prettyprint"><code>console.log(`Loaded ${store.size()} documents`);</code></pre>
1325
+
1326
+
1327
+
1328
+
1329
+
1330
+
1331
+
1332
+
1333
+
1334
+ </article>
1335
+
1336
+ </section>
1337
+
1338
+
1339
+
1340
+
1341
+ </div>
1342
+
1343
+ <nav>
1344
+ <h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="VectorStore.html">VectorStore</a></li><li><a href="VectorStoreWrapper.html">VectorStoreWrapper</a></li></ul><h3><a href="global.html">Global</a></h3>
1345
+ </nav>
1346
+
1347
+ <br class="clear">
1348
+
1349
+ <footer>
1350
+ Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 4.0.4</a>
1351
+ </footer>
1352
+
1353
+ <script> prettyPrint(); </script>
1354
+ <script src="scripts/linenumber.js"> </script>
1355
+ </body>
1356
+ </html>