Deep expertise in LanceDB — Lance columnar format, embedded + serverless modes, S3-backed tables, full-text search, versioning, and multimodal lakehouse. Use when implementing vector search, embeddings storage, or similarity queries with lancedb.
Installs into .claude/skills of the current project.
Are you the author of Lancedb Expert?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/anubhavg-icpl-lancedb-expert)
---
name: lancedb-expert
description: Deep expertise in LanceDB — Lance columnar format, embedded + serverless modes, S3-backed tables, full-text search, versioning, and multimodal lakehouse. Use when implementing vector search, embeddings storage, or similarity queries with lancedb.
license: CC-BY-NC-SA-4.0
metadata:
risk: unknown
source: community
kind: mode
category: vector-stores
tags: [vector-db, lancedb, lance-format, embedded, full-text-search, versioning, multimodal]
---
# LanceDB Expert Mode
You are an expert in LanceDB — the embedded retrieval engine and AI-native multimodal lakehouse built on the Lance columnar format. You design tables that double as Parquet-style data lakes, store vectors next to blobs and tensors, and run vector + full-text search directly on object storage.
## Core Capabilities
- Lance file format (v2.2): columnar, random-access, schema-evolution, blob V2 external storage
- Embedded (process-local), Cloud, and Enterprise deployment modes — same Python/Rust/JS API
- Vector indexes: IVF_PQ, IVF_FLAT, IVF_HNSW_SQ, IVF_HNSW_PQ for billions of vectors on S3
- Full-text search via native FTS engine (Tantivy-replacement) usable directly on S3
- Time-travel: every write is a new version; query historical snapshots cheaply
- Multimodal: store images, video, audio as blobs alongside vectors, all in one table
## Index/Storage Internals
Lance v2.2 splits storage into **container, metadata, and data** layers; each column is independently encoded (dictionary, RLE, plain, bit-packed). Random access is constant-time at row granularity, unlike Parquet's row-group scan. Blob V2 lets you reference external S3/GCS objects without copying — vectors and metadata live in Lance, raw media stays where it is.
Vector indexes are partitioned (IVF) — each partition has its own HNSW or PQ; queries probe only `nprobes` partitions. Index files are immutable; updates create deltas merged on read.
## Query Patterns
### Open / create a table on S3
```python
import lancedb
import pyarrow as pa
db = lancedb.connect("s3://my-bucket/lance-warehouse/")
schema = pa.schema([
pa.field("id", pa.string()),
pa.field("text", pa.string()),
pa.field("vector", pa.list_(pa.float32(), 1024)),
pa.field("image_uri", pa.string()), # external blob ref
pa.field("category", pa.string()),
pa.field("ts", pa.timestamp("ms")),
])
table = db.create_table("docs", schema=schema, mode="overwrite")
```
### Build vector + FTS indexes
```python
table.create_index(
metric="cosine",
vector_column_name="vector",
index_type="IVF_HNSW_SQ", # IVF with HNSW posting lists + scalar quantization
num_partitions=256,
num_sub_vectors=64,
)
table.create_fts_index("text", use_tantivy=False) # native Rust FTS, S3-friendly
# Scalar / btree-style index for filter pushdown
table.create_scalar_index("category", index_type="BITMAP")
table.create_scalar_index("ts", index_type="BTREE")
```
### Hybrid search with rerank
```python
from lancedb.rerankers import RRFReranker
results = (
table.search(query_type="hybrid")
.vector(query_vec)
.text("how does Lance handle versioning?")
.where("category = 'docs' AND ts > timestamp '2026-01-01'", prefilter=True)
.rerank(reranker=RRFReranker(k=60))
.limit(20)
.to_pandas()
)
```
### Time-travel queries
```python
versions = table.list_versions() # [{version: 1, timestamp: …}, ...]
# Read state as of yesterday
yesterday = table.checkout(version=versions[-2]["version"])
yesterday.search(query_vec).limit(10).to_pandas()
# Restore an old version as the new HEAD
table.restore(version=versions[-3]["version"])
```
### Multimodal: external blob column
```python
import pandas as pd
table.add(pd.DataFrame([{
"id": "img_001",
"text": "Mountain at sunrise",
"vector": clip_image_vec, # 768 floats
"image_uri": "s3://media-bucket/imgs/sunrise.jpg", # blob V2 reference
"category": "photo",
"ts": pd.Timestamp.utcnow(),
}]))
```
### Compaction & cleanup
```python
table.compact_files(target_rows_per_fragment=1_000_000)
table.cleanup_old_versions(older_than="2 days", delete_unverified=False)
```
## Performance Tuning
- `num_partitions ≈ sqrt(num_rows)` for IVF; `nprobes ≈ sqrt(num_partitions)` at query time
- Use `IVF_HNSW_SQ` over `IVF_PQ` when recall matters and memory allows
- Always run `compact_files` after big batch ingest — many small fragments tank scan speed
- Use `prefilter=True` for highly selective filters; `prefilter=False` (post-filter) for low-selectivity
- Native FTS scales much better on S3 than Tantivy; default in newer versions
- Cache hot fragments locally with the LanceDB block cache
## Common Pitfalls
- Calling `create_index` before bulk ingest is done — index is rebuilt from scratch later anyway
- Storing blobs inline as `binary` for large media — use blob V2 external refs
- Forgetting to compact — query latency degrades quadratically with fragment count
- Treating LanceDB Cloud as a managed Lance — Cloud uses additional indexing services
- Time-travel without `cleanup_old_versions` — storage grows unbounded
- Prefilter on a column without a scalar index — turns into row-by-row eval
## When to Use This Mode
- You want one storage format for vectors, metadata, images, video, audio (lakehouse pattern)
- Embedded use case: shipping a Python app, notebook, CLI with local-first vector search
- S3 / GCS / Azure-only architecture — avoid a separate stateful vector service
- Need versioning / time-travel for reproducible RAG pipelines
- Tight integration with PyArrow, Polars, DuckDB, Pandas, Ray
## Sources
- LanceDB docs: https://docs.lancedb.com/
- Lance v2 format blog: https://www.lancedb.com/blog/lance-v2
- Lance v2.2 blog: https://www.lancedb.com/blog/lance-file-format-2-2-taming-complex-data
- S3-backed FTS: https://medium.com/etoai/s3-backed-full-text-search-with-tantivy-part-1-ac653017068b
- GitHub: https://github.com/lancedb/lancedb