> ## Documentation Index
> Fetch the complete documentation index at: https://docs.lancedb.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Quickstart

> Get started with LanceDB in minutes.

export const TsQuickstartVectorSearch1 = "// Let's search for vectors similar to \"warrior\"\nlet queryVector = [0.8, 0.3, 0.8];\n\nlet result = await table.search(queryVector).limit(2).toArray();\nconsole.table(result);\n";

export const TsQuickstartCreateTable = "const data = [\n  { id: \"1\", text: \"knight\", vector: [0.9, 0.4, 0.8] },\n  { id: \"2\", text: \"ranger\", vector: [0.8, 0.4, 0.7] },\n  { id: \"9\", text: \"priest\", vector: [0.6, 0.2, 0.6] },\n  { id: \"4\", text: \"rogue\", vector: [0.7, 0.4, 0.7] },\n];\nlet table = await db.createTable(\"adventurers\", data, { mode: \"overwrite\" });\n";

export const RsQuickstartVectorSearch1 = "// Let's search for vectors similar to \"warrior\"\nlet query_vector = [0.8, 0.3, 0.8];\n\nlet result: DataFrame = table\n    .query()\n    .nearest_to(&query_vector)\n    .unwrap()\n    .limit(2)\n    .select(Select::Columns(vec![\"text\".to_string()]))\n    .execute()\n    .await\n    .unwrap()\n    .into_polars()\n    .await\n    .unwrap();\nprintln!(\"{result:?}\");\n";

export const RsQuickstartDefineStruct = "// Define a struct representing the data schema\n#[derive(Debug, Clone, Serialize, Deserialize)]\nstruct Adventurer {\n    id: String,\n    text: String,\n    vector: [f32; 3],\n}\n\nfn adventurers_schema() -> Arc<Schema> {\n    Arc::new(Schema::new(vec![\n        Field::new(\"id\", DataType::LargeUtf8, false),\n        Field::new(\"text\", DataType::LargeUtf8, false),\n        Field::new(\n            \"vector\",\n            DataType::FixedSizeList(Arc::new(Field::new(\"item\", DataType::Float32, true)), 3),\n            false,\n        ),\n    ]))\n}\n";

export const RsQuickstartCreateTable = "// Define an arrow schema named adventurers_schema beforehand (omitted here for brevity)\nlet schema = adventurers_schema();\nlet data = vec![\n    Adventurer {\n        id: \"1\".to_string(),\n        text: \"knight\".to_string(),\n        vector: [0.9, 0.4, 0.8],\n    },\n    Adventurer {\n        id: \"2\".to_string(),\n        text: \"ranger\".to_string(),\n        vector: [0.8, 0.4, 0.7],\n    },\n    Adventurer {\n        id: \"9\".to_string(),\n        text: \"priest\".to_string(),\n        vector: [0.6, 0.2, 0.6],\n    },\n    Adventurer {\n        id: \"4\".to_string(),\n        text: \"rogue\".to_string(),\n        vector: [0.7, 0.4, 0.7],\n    },\n];\n// Create a new table with the data, overwriting if it already exists\nlet mut table = db\n    .create_table(\"adventurers\", adventurers_to_reader(schema.clone(), &data))\n    .mode(CreateTableMode::Overwrite)\n    .execute()\n    .await\n    .unwrap();\n";

export const PyQuickstartOutputPandas = "# Ensure you run `pip install pandas` beforehand\nresult = table.search(query_vector).limit(2).to_pandas()\nprint(result)\n";

export const PyQuickstartVectorSearch1Async = "# Let's search for vectors similar to \"warrior\"\nquery_vector = [0.8, 0.3, 0.8]\n\n# Ensure you run `pip install polars` beforehand\nasync_result = await (await async_table.search(query_vector)).limit(2).to_polars()\nprint(async_result)\n";

export const PyQuickstartVectorSearch1 = "# Let's search for vectors similar to \"warrior\"\nquery_vector = [0.8, 0.3, 0.8]\n\n# Ensure you run `pip install polars` beforehand\nresult = table.search(query_vector).limit(2).to_polars()\nprint(result)\n";

export const PyQuickstartCreateTableAsync = "async_table = await async_db.create_table(\n    \"adventurers\",\n    data=data,\n    mode=\"overwrite\",\n)\n";

export const PyQuickstartCreateTable = "data = [\n    {\"id\": \"1\", \"text\": \"knight\", \"vector\": [0.9, 0.4, 0.8]},\n    {\"id\": \"2\", \"text\": \"ranger\", \"vector\": [0.8, 0.4, 0.7]},\n    {\"id\": \"9\", \"text\": \"priest\", \"vector\": [0.6, 0.2, 0.6]},\n    {\"id\": \"4\", \"text\": \"rogue\", \"vector\": [0.7, 0.4, 0.7]},\n]\ntable = db.create_table(\"adventurers\", data=data, mode=\"overwrite\")\n";

export const TsConnectObjectStorage = "async function connectObjectStorageExample() {\n  const uri = \"s3://your-bucket/path\";\n  // You can also use \"gs://your-bucket/path\" or \"az://your-container/path\".\n  const db = await lancedb.connect(uri);\n  return db;\n}\n";

export const TsConnectEnterprise = "const uri = \"db://your-database-uri\";\nconst apiKey = \"your-api-key\";\nconst region = \"us-east-1\";\n";

export const TsConnect = "import * as lancedb from \"@lancedb/lancedb\";\n\nasync function connectExample(uri: string) {\n  const db = await lancedb.connect(uri);\n  return db;\n}\n";

export const RsConnectObjectStorage = "let uri = \"s3://your-bucket/path\";\n// You can also use \"gs://your-bucket/path\" or \"az://your-container/path\".\n";

export const RsConnectEnterprise = "let uri = \"db://your-database-uri\";\nlet api_key = \"your-api-key\";\nlet region = \"us-east-1\";\n";

export const RsConnect = "async fn connect_example(uri: &str) {\n    let db = connect(uri).execute().await.unwrap();\n    let _ = db;\n}\n";

export const PyConnectObjectStorageAsync = "import lancedb\n\nuri = \"s3://your-bucket/path\"\n# You can also use \"gs://your-bucket/path\" or \"az://your-container/path\".\nasync_db = await lancedb.connect_async(uri)\n";

export const PyConnectObjectStorage = "import lancedb\n\nuri = \"s3://your-bucket/path\"\n# You can also use \"gs://your-bucket/path\" or \"az://your-container/path\".\ndb = lancedb.connect(uri)\n";

export const PyConnectEnterpriseAsync = "uri = \"db://your-database-uri\"\napi_key = \"your-api-key\"\nregion = \"us-east-1\"\n";

export const PyConnectEnterprise = "uri = \"db://your-database-uri\"\napi_key = \"your-api-key\"\nregion = \"us-east-1\"\n";

export const PyConnectAsync = "import lancedb\n\nuri = \"ex_lancedb\"\nasync_db = await lancedb.connect_async(uri)\n";

export const PyConnect = "import lancedb\n\nuri = \"ex_lancedb\"\ndb = lancedb.connect(uri)\n";

The easiest way to get started with LanceDB is the open source version, which is an embedded database that
runs in-process (like SQLite). Let's get started in just a few steps!

## 1. Install LanceDB

Install LanceDB in your client SDK.

<CodeGroup>
  ```bash Python icon=Python theme={"theme":{"light":"vitesse-light","dark":"catppuccin-mocha"}}
  pip install lancedb  # or uv add lancedb
  ```

  ```bash TypeScript icon=js theme={"theme":{"light":"vitesse-light","dark":"catppuccin-mocha"}}
  npm install @lancedb/lancedb
  ```

  ```bash Rust icon=Rust theme={"theme":{"light":"vitesse-light","dark":"catppuccin-mocha"}}
  cargo add lancedb
  ```
</CodeGroup>

## 2. Connect to a LanceDB database

LanceDB supports several URI patterns to connect to a database.

* A local filesystem path (when using it as an embedded library)
* A `db://...` URI (when using LanceDB Enterprise)
* An object storage URI: `s3://...`, `gs://...`, or `az://...` (OSS mode)

### Connect via local path with LanceDB

The simplest way to begin is to use LanceDB OSS. Simply import LanceDB as an embedded library in your
client SDK of choice and point to a local path.

<CodeGroup>
  <CodeBlock filename="Python (sync)" language="Python" icon="python">
    {PyConnect}
  </CodeBlock>

  <CodeBlock filename="Python (async)" language="Python" icon="python">
    {PyConnectAsync}
  </CodeBlock>

  <CodeBlock filename="TypeScript" language="TypeScript" icon="square-js">
    {TsConnect}
  </CodeBlock>

  <CodeBlock filename="Rust" language="Rust" icon="rust">
    { "use lancedb::connect;\n" }

    { "\n" }

    {RsConnect}
  </CodeBlock>
</CodeGroup>

### Connect via object storage URIs

You can also connect LanceDB OSS directly to object storage:

<CodeGroup>
  <CodeBlock filename="Python (sync)" language="Python" icon="python">
    {PyConnectObjectStorage}
  </CodeBlock>

  <CodeBlock filename="Python (async)" language="Python" icon="python">
    {PyConnectObjectStorageAsync}
  </CodeBlock>

  <CodeBlock filename="TypeScript" language="TypeScript" icon="square-js">
    {TsConnectObjectStorage}
  </CodeBlock>

  <CodeBlock filename="Rust" language="Rust" icon="rust">
    {RsConnectObjectStorage}
  </CodeBlock>
</CodeGroup>

For credentials, endpoints, and provider-specific options, see
[Configuring storage](/storage/configuration).

### Connect to LanceDB Enterprise

If you're using LanceDB Enterprise, you can connect using a `db://` URI,
along with any necessary credentials. Simply replace the local path with a remote `uri`
that points to where your data is stored, and you're ready to go.

<CodeGroup>
  <CodeBlock filename="Python (sync)" language="Python" icon="python">
    {PyConnectEnterprise}
  </CodeBlock>

  <CodeBlock filename="Python (async)" language="Python" icon="python">
    {PyConnectEnterpriseAsync}
  </CodeBlock>

  <CodeBlock filename="TypeScript" language="TypeScript" icon="square-js">
    {TsConnectEnterprise}
  </CodeBlock>

  <CodeBlock filename="Rust" language="Rust" icon="rust">
    {RsConnectEnterprise}
  </CodeBlock>
</CodeGroup>

To learn more about LanceDB Enterprise, see the [Enterprise documentation](/enterprise).

## 3. Obtain data and ingest into LanceDB

Let's look at an example. We have the following records of characters in an adventure board game.
The vector column holds 3-dimensional embeddings representing each character.

To ingest the data into LanceDB, obtain data of the required shape
and pass in the data object to the `create_table` method as shown below.
Note that LanceDB tables require a schema. If you don't provide one, LanceDB
will infer it from the data. For the Rust snippet, you can find the helper functions in the
[code](https://github.com/lancedb/docs/blob/main/tests/rs/quickstart.rs).

<CodeGroup>
  <CodeBlock filename="Python (sync)" language="Python" icon="python">
    {PyQuickstartCreateTable}
  </CodeBlock>

  <CodeBlock filename="Python (async)" language="Python" icon="python">
    {PyQuickstartCreateTableAsync}
  </CodeBlock>

  <CodeBlock filename="TypeScript" language="TypeScript" icon="square-js">
    {TsQuickstartCreateTable}
  </CodeBlock>

  <CodeBlock filename="Rust" language="Rust" icon="rust">
    {RsQuickstartDefineStruct}

    {RsQuickstartCreateTable}
  </CodeBlock>
</CodeGroup>

<Warning>
  The `vector` arrays here are synthetic and for demonstration purposes only. In your real-world
  applications, you'd generate these vectors from the raw text fields using a suitable embedding model.
</Warning>

## 4. Run a vector similarity search

Now, let's perform a vector similarity search. The query vector should have the same
dimensionality as your data vectors and be generated using the same embedding model.
The search returns the most similar vectors based on a chosen distance metric (default is L2,
or Euclidean distance).

Our query is a vector that represents a "warrior". Let's find the result that's most similar
to it!

<CodeGroup>
  <CodeBlock filename="Python (sync)" language="Python" icon="python">
    {PyQuickstartVectorSearch1}
  </CodeBlock>

  <CodeBlock filename="Python (async)" language="Python" icon="python">
    {PyQuickstartVectorSearch1Async}
  </CodeBlock>

  <CodeBlock filename="TypeScript" language="TypeScript" icon="square-js">
    {TsQuickstartVectorSearch1}
  </CodeBlock>

  <CodeBlock filename="Rust" language="Rust" icon="rust">
    {RsQuickstartVectorSearch1}
  </CodeBlock>
</CodeGroup>

The example for Python above shows how to convert results to a Polars DataFrame.
Depending on your language, you can collect query results as a list/array of objects or DataFrames
to be used downstream in your application.

<Accordion title="Pandas users in Python can get results as a Pandas DataFrame">
  Use the `to_pandas()` method to convert query results into a Pandas DataFrame.

  <CodeBlock filename="Python" language="Python" icon="python">
    {PyQuickstartOutputPandas}
  </CodeBlock>
</Accordion>

<Info>
  See the full code for these examples (including helper functions) in the
  `quickstart` file for the appropriate client language in the
  [files provided here](https://github.com/lancedb/docs/tree/main/tests).
</Info>

## What's next?

You've learned how to install LanceDB, connect, create a table, and run a first
vector search. In the real world, embeddings capture meaning and vector search
allows you to find the most relevant data based on semantic similarity.

Note that LanceDB is much more than "just a vector database" -- it's
[a multimodal lakehouse](https://lancedb.com/blog/multimodal-lakehouse/).
There's a lot more you can do with it! Continue
to the [Table management](/tables/) guide to build on
this example with schema options, appending data, updates, and versioning.

As you explore LanceDB further, you can combine vector search with other techniques like filtering based
on metadata fields, full-text search, hybrid search, and more. Check out the tutorials
and guides below to continue learning.

<Columns cols={2}>
  <Card title="Basic table operations" icon="table" href="/tables">
    Build on this quickstart with table creation, updates, and schema tips.
  </Card>

  <Card title="Build a RAG App" icon="search" href="/tutorials/agents/">
    Learn how to build Retrieval-Augmented Generation (RAG) applications using LanceDB.
  </Card>
</Columns>
