| 1 | [**@lancedb/lancedb**](../README.md) • **Docs** |
| 2 | |
| 3 | *** |
| 4 | |
| 5 | [@lancedb/lancedb](../globals.md) / Index |
| 6 | |
| 7 | # Class: Index |
| 8 | |
| 9 | ## Methods |
| 10 | |
| 11 | ### btree() |
| 12 | |
| 13 | > `static` **btree**(): [`Index`](Index.md) |
| 14 | |
| 15 | Create a btree index |
| 16 | |
| 17 | A btree index is an index on a scalar columns. The index stores a copy of the column |
| 18 | in sorted order. A header entry is created for each block of rows (currently the |
| 19 | block size is fixed at 4096). These header entries are stored in a separate |
| 20 | cacheable structure (a btree). To search for data the header is used to determine |
| 21 | which blocks need to be read from disk. |
| 22 | |
| 23 | For example, a btree index in a table with 1Bi rows requires sizeof(Scalar) * 256Ki |
| 24 | bytes of memory and will generally need to read sizeof(Scalar) * 4096 bytes to find |
| 25 | the correct row ids. |
| 26 | |
| 27 | This index is good for scalar columns with mostly distinct values and does best when |
| 28 | the query is highly selective. |
| 29 | |
| 30 | The btree index does not currently have any parameters though parameters such as the |
| 31 | block size may be added in the future. |
| 32 | |
| 33 | #### Returns |
| 34 | |
| 35 | [`Index`](Index.md) |
| 36 | |
| 37 | *** |
| 38 | |
| 39 | ### ivfPq() |
| 40 | |
| 41 | > `static` **ivfPq**(`options`?): [`Index`](Index.md) |
| 42 | |
| 43 | Create an IvfPq index |
| 44 | |
| 45 | This index stores a compressed (quantized) copy of every vector. These vectors |
| 46 | are grouped into partitions of similar vectors. Each partition keeps track of |
| 47 | a centroid which is the average value of all vectors in the group. |
| 48 | |
| 49 | During a query the centroids are compared with the query vector to find the closest |
| 50 | partitions. The compressed vectors in these partitions are then searched to find |
| 51 | the closest vectors. |
| 52 | |
| 53 | The compression scheme is called product quantization. Each vector is divided into |
| 54 | subvectors and then each subvector is quantized into a small number of bits. the |
| 55 | parameters `num_bits` and `num_subvectors` control this process, providing a tradeoff |
| 56 | between index size (and thus search speed) and index accuracy. |
| 57 | |
| 58 | The partitioning process is called IVF and the `num_partitions` parameter controls how |
| 59 | many groups to create. |
| 60 | |
| 61 | Note that training an IVF PQ index on a large dataset is a slow operation and |
| 62 | currently is also a memory intensive operation. |
| 63 | |
| 64 | #### Parameters |
| 65 | |
| 66 | • **options?**: `Partial`<[`IvfPqOptions`](../interfaces/IvfPqOptions.md)> |
| 67 | |
| 68 | #### Returns |
| 69 | |
| 70 | [`Index`](Index.md) |
| 71 | |
| 72 | ### fts() |
| 73 | |
| 74 | > `static` **fts**(`options`?): [`Index`](Index.md) |
| 75 | |
| 76 | Create a full text search index |
| 77 | |
| 78 | This index is used to search for text data. The index is created by tokenizing the text |
| 79 | into words and then storing occurrences of these words in a data structure called inverted index |
| 80 | that allows for fast search. |
| 81 | |
| 82 | During a search the query is tokenized and the inverted index is used to find the rows that |
| 83 | contain the query words. The rows are then scored based on BM25 and the top scoring rows are |
| 84 | sorted and returned. |
| 85 | |
| 86 | #### Parameters |
| 87 | |
| 88 | • **options?**: `Partial`<[`FtsOptions`](../interfaces/FtsOptions.md)> |
| 89 | |
| 90 | #### Returns |
| 91 | |
| 92 | [`Index`](Index.md) |