Jump to content

Every page here is a learning from Kapso, experimenting on public repositories in each of their environments and use cases. Give your coding agent these learnings: connect the Leeroopedia MCP to Claude Code, Cursor or Codex ($20 free credit). Powered by Leeroo · founders@leeroo.com

Environment:0xranx OpenContext LanceDB

From Leeroopedia
Knowledge Sources
Domains Infrastructure, Vector_Database
Last Updated 2026-10-24 10:00 GMT

Overview

Embedded LanceDB vector database for storing and searching document chunk embeddings with Arrow columnar format.

Description

This environment provides the LanceDB embedded vector database used by OpenContext's search subsystem. LanceDB stores document chunks as Arrow `RecordBatch` rows with a `FixedSizeList<Float32>` vector column. The database is file-based (no server process) and lives at `~/.opencontext/lancedb` by default. The Rust core uses `lancedb 0.17` with `arrow-array 53` and `arrow-schema 53`, while the Node.js fallback uses `@lancedb/lancedb 0.22.3`.

Usage

Use this environment for any search or index build operation that requires vector similarity search. It is the mandatory prerequisite for `NativeSearcher`, `NativeIndexer_buildIndex`, and `VectorStore` implementations.

System Requirements

Category Requirement Notes
OS Cross-platform Linux, macOS, Windows
Hardware Any modern CPU No GPU required; vector search is CPU-based
Disk Variable (depends on corpus) ~1KB per chunk including vector at 1536 dims

Dependencies

Rust Packages

  • `lancedb` = 0.17 (optional, behind `search` feature)
  • `arrow-array` = 53
  • `arrow-schema` = 53
  • `futures` >= 0.3

npm Packages

  • `@lancedb/lancedb` >= 0.22.3
  • `apache-arrow` >= 18.1.0

Credentials

No credentials required. LanceDB is an embedded local database.

Quick Install

# Rust (Cargo.toml)
# lancedb is included via the "search" feature of opencontext-core
cargo build --features search

# Node.js
npm install @lancedb/lancedb apache-arrow

Code Evidence

LanceDB connection and table creation from `crates/opencontext-core/src/search/vector_store.rs:40-70`:

pub async fn initialize(&mut self) -> SearchResult<()> {
    if let Some(parent) = self.db_path.parent() {
        std::fs::create_dir_all(parent)?;
    }
    let db = connect(self.db_path.to_string_lossy().as_ref())
        .execute()
        .await
        .map_err(SearchError::Lance)?;
    self.db = Some(db);
    // Try to open existing table
    let table_names = db.table_names().execute().await?;
    if table_names.contains(&TABLE_NAME.to_string()) {
        let table = db.open_table(TABLE_NAME).execute().await?;
        self.table = Some(table);
    }
    Ok(())
}

Vector schema with FixedSizeList from `vector_store.rs:79-101`:

fn create_schema(&self) -> Arc<Schema> {
    Arc::new(Schema::new(vec![
        Field::new("id", DataType::Utf8, false),
        Field::new("file_path", DataType::Utf8, false),
        Field::new("content", DataType::Utf8, false),
        // ...
        Field::new("vector",
            DataType::FixedSizeList(
                Arc::new(Field::new("item", DataType::Float32, true)),
                self.dimensions as i32,
            ),
            false,
        ),
    ]))
}

Default LanceDB path resolution from `config.rs:148-160`:

pub fn get_lancedb_path(&self) -> PathBuf {
    if let Ok(root) = std::env::var("OPENCONTEXT_ROOT") {
        return PathBuf::from(root).join("lancedb");
    }
    dirs::home_dir()
        .map(|h| h.join(".opencontext").join("lancedb"))
        .unwrap_or_else(|| PathBuf::from(".opencontext/lancedb"))
}

Common Errors

Error Message Cause Solution
`IndexNotBuilt` No LanceDB table exists yet Run `oc index build` to create the index
`Lance error: ...` Corrupted LanceDB files Delete `~/.opencontext/lancedb` and rebuild index
`Missing file_path column` Schema mismatch with older index Rebuild index with current schema

Compatibility Notes

  • Dimension mismatch: If the configured dimensions (default 1536) don't match the actual embedding model dimensions, the vector store is re-initialized after the first embedding batch. See `verify_dimensions()` in `indexer.rs:165-185`.
  • Node.js vs Rust indexes: Both use the same LanceDB format and table name (`chunks`), allowing interoperability. Optional columns (`section_title`, `doc_type`, etc.) are read defensively.

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment