| 1 | [vectordb](../README.md) / [Exports](../modules.md) / Query |
| 2 | |
| 3 | # Class: Query\<T\> |
| 4 | |
| 5 | A builder for nearest neighbor queries for LanceDB. |
| 6 | |
| 7 | ## Type parameters |
| 8 | |
| 9 | | Name | Type | |
| 10 | | :------ | :------ | |
| 11 | | `T` | `number`[] | |
| 12 | |
| 13 | ## Table of contents |
| 14 | |
| 15 | ### Constructors |
| 16 | |
| 17 | - [constructor](Query.md#constructor) |
| 18 | |
| 19 | ### Properties |
| 20 | |
| 21 | - [\_embeddings](Query.md#_embeddings) |
| 22 | - [\_fastSearch](Query.md#_fastsearch) |
| 23 | - [\_filter](Query.md#_filter) |
| 24 | - [\_limit](Query.md#_limit) |
| 25 | - [\_metricType](Query.md#_metrictype) |
| 26 | - [\_nprobes](Query.md#_nprobes) |
| 27 | - [\_prefilter](Query.md#_prefilter) |
| 28 | - [\_query](Query.md#_query) |
| 29 | - [\_queryVector](Query.md#_queryvector) |
| 30 | - [\_refineFactor](Query.md#_refinefactor) |
| 31 | - [\_select](Query.md#_select) |
| 32 | - [\_tbl](Query.md#_tbl) |
| 33 | - [where](Query.md#where) |
| 34 | |
| 35 | ### Methods |
| 36 | |
| 37 | - [execute](Query.md#execute) |
| 38 | - [fastSearch](Query.md#fastsearch) |
| 39 | - [filter](Query.md#filter) |
| 40 | - [isElectron](Query.md#iselectron) |
| 41 | - [limit](Query.md#limit) |
| 42 | - [metricType](Query.md#metrictype) |
| 43 | - [nprobes](Query.md#nprobes) |
| 44 | - [prefilter](Query.md#prefilter) |
| 45 | - [refineFactor](Query.md#refinefactor) |
| 46 | - [select](Query.md#select) |
| 47 | |
| 48 | ## Constructors |
| 49 | |
| 50 | ### constructor |
| 51 | |
| 52 | • **new Query**\<`T`\>(`query?`, `tbl?`, `embeddings?`) |
| 53 | |
| 54 | #### Type parameters |
| 55 | |
| 56 | | Name | Type | |
| 57 | | :------ | :------ | |
| 58 | | `T` | `number`[] | |
| 59 | |
| 60 | #### Parameters |
| 61 | |
| 62 | | Name | Type | |
| 63 | | :------ | :------ | |
| 64 | | `query?` | `T` | |
| 65 | | `tbl?` | `any` | |
| 66 | | `embeddings?` | [`EmbeddingFunction`](../interfaces/EmbeddingFunction.md)\<`T`\> | |
| 67 | |
| 68 | #### Defined in |
| 69 | |
| 70 | [query.ts:39](https://github.com/lancedb/lancedb/blob/92179835/node/src/query.ts#L39) |
| 71 | |
| 72 | ## Properties |
| 73 | |
| 74 | ### \_embeddings |
| 75 | |
| 76 | • `Protected` `Optional` `Readonly` **\_embeddings**: [`EmbeddingFunction`](../interfaces/EmbeddingFunction.md)\<`T`\> |
| 77 | |
| 78 | #### Defined in |
| 79 | |
| 80 | [query.ts:37](https://github.com/lancedb/lancedb/blob/92179835/node/src/query.ts#L37) |
| 81 | |
| 82 | ___ |
| 83 | |
| 84 | ### \_fastSearch |
| 85 | |
| 86 | • `Private` **\_fastSearch**: `boolean` |
| 87 | |
| 88 | #### Defined in |
| 89 | |
| 90 | [query.ts:36](https://github.com/lancedb/lancedb/blob/92179835/node/src/query.ts#L36) |
| 91 | |
| 92 | ___ |
| 93 | |
| 94 | ### \_filter |
| 95 | |
| 96 | • `Private` `Optional` **\_filter**: `string` |
| 97 | |
| 98 | #### Defined in |
| 99 | |
| 100 | [query.ts:33](https://github.com/lancedb/lancedb/blob/92179835/node/src/query.ts#L33) |
| 101 | |
| 102 | ___ |
| 103 | |
| 104 | ### \_limit |
| 105 | |
| 106 | • `Private` `Optional` **\_limit**: `number` |
| 107 | |
| 108 | #### Defined in |
| 109 | |
| 110 | [query.ts:29](https://github.com/lancedb/lancedb/blob/92179835/node/src/query.ts#L29) |
| 111 | |
| 112 | ___ |
| 113 | |
| 114 | ### \_metricType |
| 115 | |
| 116 | • `Private` `Optional` **\_metricType**: [`MetricType`](../enums/MetricType.md) |
| 117 | |
| 118 | #### Defined in |
| 119 | |
| 120 | [query.ts:34](https://github.com/lancedb/lancedb/blob/92179835/node/src/query.ts#L34) |
| 121 | |
| 122 | ___ |
| 123 | |
| 124 | ### \_nprobes |
| 125 | |
| 126 | • `Private` **\_nprobes**: `number` |
| 127 | |
| 128 | #### Defined in |
| 129 | |
| 130 | [query.ts:31](https://github.com/lancedb/lancedb/blob/92179835/node/src/query.ts#L31) |
| 131 | |
| 132 | ___ |
| 133 | |
| 134 | ### \_prefilter |
| 135 | |
| 136 | • `Private` **\_prefilter**: `boolean` |
| 137 | |
| 138 | #### Defined in |
| 139 | |
| 140 | [query.ts:35](https://github.com/lancedb/lancedb/blob/92179835/node/src/query.ts#L35) |
| 141 | |
| 142 | ___ |
| 143 | |
| 144 | ### \_query |
| 145 | |
| 146 | • `Private` `Optional` `Readonly` **\_query**: `T` |
| 147 | |
| 148 | #### Defined in |
| 149 | |
| 150 | [query.ts:26](https://github.com/lancedb/lancedb/blob/92179835/node/src/query.ts#L26) |
| 151 | |
| 152 | ___ |
| 153 | |
| 154 | ### \_queryVector |
| 155 | |
| 156 | • `Private` `Optional` **\_queryVector**: `number`[] |
| 157 | |
| 158 | #### Defined in |
| 159 | |
| 160 | [query.ts:28](https://github.com/lancedb/lancedb/blob/92179835/node/src/query.ts#L28) |
| 161 | |
| 162 | ___ |
| 163 | |
| 164 | ### \_refineFactor |
| 165 | |
| 166 | • `Private` `Optional` **\_refineFactor**: `number` |
| 167 | |
| 168 | #### Defined in |
| 169 | |
| 170 | [query.ts:30](https://github.com/lancedb/lancedb/blob/92179835/node/src/query.ts#L30) |
| 171 | |
| 172 | ___ |
| 173 | |
| 174 | ### \_select |
| 175 | |
| 176 | • `Private` `Optional` **\_select**: `string`[] |
| 177 | |
| 178 | #### Defined in |
| 179 | |
| 180 | [query.ts:32](https://github.com/lancedb/lancedb/blob/92179835/node/src/query.ts#L32) |
| 181 | |
| 182 | ___ |
| 183 | |
| 184 | ### \_tbl |
| 185 | |
| 186 | • `Private` `Optional` `Readonly` **\_tbl**: `any` |
| 187 | |
| 188 | #### Defined in |
| 189 | |
| 190 | [query.ts:27](https://github.com/lancedb/lancedb/blob/92179835/node/src/query.ts#L27) |
| 191 | |
| 192 | ___ |
| 193 | |
| 194 | ### where |
| 195 | |
| 196 | • **where**: (`value`: `string`) => [`Query`](Query.md)\<`T`\> |
| 197 | |
| 198 | #### Type declaration |
| 199 | |
| 200 | ▸ (`value`): [`Query`](Query.md)\<`T`\> |
| 201 | |
| 202 | A filter statement to be applied to this query. |
| 203 | |
| 204 | ##### Parameters |
| 205 | |
| 206 | | Name | Type | Description | |
| 207 | | :------ | :------ | :------ | |
| 208 | | `value` | `string` | A filter in the same format used by a sql WHERE clause. | |
| 209 | |
| 210 | ##### Returns |
| 211 | |
| 212 | [`Query`](Query.md)\<`T`\> |
| 213 | |
| 214 | #### Defined in |
| 215 | |
| 216 | [query.ts:90](https://github.com/lancedb/lancedb/blob/92179835/node/src/query.ts#L90) |
| 217 | |
| 218 | ## Methods |
| 219 | |
| 220 | ### execute |
| 221 | |
| 222 | ▸ **execute**\<`T`\>(): `Promise`\<`T`[]\> |
| 223 | |
| 224 | Execute the query and return the results as an Array of Objects |
| 225 | |
| 226 | #### Type parameters |
| 227 | |
| 228 | | Name | Type | |
| 229 | | :------ | :------ | |
| 230 | | `T` | `Record`\<`string`, `unknown`\> | |
| 231 | |
| 232 | #### Returns |
| 233 | |
| 234 | `Promise`\<`T`[]\> |
| 235 | |
| 236 | #### Defined in |
| 237 | |
| 238 | [query.ts:127](https://github.com/lancedb/lancedb/blob/92179835/node/src/query.ts#L127) |
| 239 | |
| 240 | ___ |
| 241 | |
| 242 | ### fastSearch |
| 243 | |
| 244 | ▸ **fastSearch**(`value`): [`Query`](Query.md)\<`T`\> |
| 245 | |
| 246 | Skip searching un-indexed data. This can make search faster, but will miss |
| 247 | any data that is not yet indexed. |
| 248 | |
| 249 | #### Parameters |
| 250 | |
| 251 | | Name | Type | |
| 252 | | :------ | :------ | |
| 253 | | `value` | `boolean` | |
| 254 | |
| 255 | #### Returns |
| 256 | |
| 257 | [`Query`](Query.md)\<`T`\> |
| 258 | |
| 259 | #### Defined in |
| 260 | |
| 261 | [query.ts:119](https://github.com/lancedb/lancedb/blob/92179835/node/src/query.ts#L119) |
| 262 | |
| 263 | ___ |
| 264 | |
| 265 | ### filter |
| 266 | |
| 267 | ▸ **filter**(`value`): [`Query`](Query.md)\<`T`\> |
| 268 | |
| 269 | A filter statement to be applied to this query. |
| 270 | |
| 271 | #### Parameters |
| 272 | |
| 273 | | Name | Type | Description | |
| 274 | | :------ | :------ | :------ | |
| 275 | | `value` | `string` | A filter in the same format used by a sql WHERE clause. | |
| 276 | |
| 277 | #### Returns |
| 278 | |
| 279 | [`Query`](Query.md)\<`T`\> |
| 280 | |
| 281 | #### Defined in |
| 282 | |
| 283 | [query.ts:85](https://github.com/lancedb/lancedb/blob/92179835/node/src/query.ts#L85) |
| 284 | |
| 285 | ___ |
| 286 | |
| 287 | ### isElectron |
| 288 | |
| 289 | ▸ `Private` **isElectron**(): `boolean` |
| 290 | |
| 291 | #### Returns |
| 292 | |
| 293 | `boolean` |
| 294 | |
| 295 | #### Defined in |
| 296 | |
| 297 | [query.ts:155](https://github.com/lancedb/lancedb/blob/92179835/node/src/query.ts#L155) |
| 298 | |
| 299 | ___ |
| 300 | |
| 301 | ### limit |
| 302 | |
| 303 | ▸ **limit**(`value`): [`Query`](Query.md)\<`T`\> |
| 304 | |
| 305 | Sets the number of results that will be returned |
| 306 | default value is 10 |
| 307 | |
| 308 | #### Parameters |
| 309 | |
| 310 | | Name | Type | Description | |
| 311 | | :------ | :------ | :------ | |
| 312 | | `value` | `number` | number of results | |
| 313 | |
| 314 | #### Returns |
| 315 | |
| 316 | [`Query`](Query.md)\<`T`\> |
| 317 | |
| 318 | #### Defined in |
| 319 | |
| 320 | [query.ts:58](https://github.com/lancedb/lancedb/blob/92179835/node/src/query.ts#L58) |
| 321 | |
| 322 | ___ |
| 323 | |
| 324 | ### metricType |
| 325 | |
| 326 | ▸ **metricType**(`value`): [`Query`](Query.md)\<`T`\> |
| 327 | |
| 328 | The MetricType used for this Query. |
| 329 | |
| 330 | #### Parameters |
| 331 | |
| 332 | | Name | Type | Description | |
| 333 | | :------ | :------ | :------ | |
| 334 | | `value` | [`MetricType`](../enums/MetricType.md) | The metric to the. | |
| 335 | |
| 336 | #### Returns |
| 337 | |
| 338 | [`Query`](Query.md)\<`T`\> |
| 339 | |
| 340 | **`See`** |
| 341 | |
| 342 | MetricType for the different options |
| 343 | |
| 344 | #### Defined in |
| 345 | |
| 346 | [query.ts:105](https://github.com/lancedb/lancedb/blob/92179835/node/src/query.ts#L105) |
| 347 | |
| 348 | ___ |
| 349 | |
| 350 | ### nprobes |
| 351 | |
| 352 | ▸ **nprobes**(`value`): [`Query`](Query.md)\<`T`\> |
| 353 | |
| 354 | The number of probes used. A higher number makes search more accurate but also slower. |
| 355 | |
| 356 | #### Parameters |
| 357 | |
| 358 | | Name | Type | Description | |
| 359 | | :------ | :------ | :------ | |
| 360 | | `value` | `number` | The number of probes used. | |
| 361 | |
| 362 | #### Returns |
| 363 | |
| 364 | [`Query`](Query.md)\<`T`\> |
| 365 | |
| 366 | #### Defined in |
| 367 | |
| 368 | [query.ts:76](https://github.com/lancedb/lancedb/blob/92179835/node/src/query.ts#L76) |
| 369 | |
| 370 | ___ |
| 371 | |
| 372 | ### prefilter |
| 373 | |
| 374 | ▸ **prefilter**(`value`): [`Query`](Query.md)\<`T`\> |
| 375 | |
| 376 | #### Parameters |
| 377 | |
| 378 | | Name | Type | |
| 379 | | :------ | :------ | |
| 380 | | `value` | `boolean` | |
| 381 | |
| 382 | #### Returns |
| 383 | |
| 384 | [`Query`](Query.md)\<`T`\> |
| 385 | |
| 386 | #### Defined in |
| 387 | |
| 388 | [query.ts:110](https://github.com/lancedb/lancedb/blob/92179835/node/src/query.ts#L110) |
| 389 | |
| 390 | ___ |
| 391 | |
| 392 | ### refineFactor |
| 393 | |
| 394 | ▸ **refineFactor**(`value`): [`Query`](Query.md)\<`T`\> |
| 395 | |
| 396 | Refine the results by reading extra elements and re-ranking them in memory. |
| 397 | |
| 398 | #### Parameters |
| 399 | |
| 400 | | Name | Type | Description | |
| 401 | | :------ | :------ | :------ | |
| 402 | | `value` | `number` | refine factor to use in this query. | |
| 403 | |
| 404 | #### Returns |
| 405 | |
| 406 | [`Query`](Query.md)\<`T`\> |
| 407 | |
| 408 | #### Defined in |
| 409 | |
| 410 | [query.ts:67](https://github.com/lancedb/lancedb/blob/92179835/node/src/query.ts#L67) |
| 411 | |
| 412 | ___ |
| 413 | |
| 414 | ### select |
| 415 | |
| 416 | ▸ **select**(`value`): [`Query`](Query.md)\<`T`\> |
| 417 | |
| 418 | Return only the specified columns. |
| 419 | |
| 420 | #### Parameters |
| 421 | |
| 422 | | Name | Type | Description | |
| 423 | | :------ | :------ | :------ | |
| 424 | | `value` | `string`[] | Only select the specified columns. If not specified, all columns will be returned. | |
| 425 | |
| 426 | #### Returns |
| 427 | |
| 428 | [`Query`](Query.md)\<`T`\> |
| 429 | |
| 430 | #### Defined in |
| 431 | |
| 432 | [query.ts:96](https://github.com/lancedb/lancedb/blob/92179835/node/src/query.ts#L96) |