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