Skip to main content
Glama

LanceDB Node

by vurtnec

LanceDB Node.js 向量搜索

使用 LanceDB 和 Ollama 的嵌入模型进行向量搜索的 Node.js 实现。

概述

该项目演示了如何:

  • 连接到 LanceDB 数据库
  • 使用 Ollama 创建自定义嵌入函数
  • 对存储的文档执行向量相似性搜索
  • 处理并显示搜索结果

先决条件

  • Node.js(v14 或更高版本)
  • Ollama 使用nomic-embed-text模型在本地运行
  • 具有读/写权限的 LanceDB 存储位置

安装

  1. 克隆存储库
  2. 安装依赖项:
pnpm install

依赖项

  • @lancedb/lancedb :Node.js 的 LanceDB 客户端
  • apache-arrow :用于处理列式数据
  • node-fetch :用于向 Ollama 发出 API 调用

用法

运行向量搜索测试脚本:

pnpm test-vector-search

或者直接执行:

node test-vector-search.js

配置

该脚本连接到:

  • LanceDB 在配置的路径下
  • Ollama API 位于http://localhost:11434/api/embeddings

MCP 配置

要与 Claude Desktop 作为 MCP 服务集成,请将以下内容添加到您的 MCP 配置 JSON 中:

{ "mcpServers": { "lanceDB": { "command": "node", "args": [ "/path/to/lancedb-node/dist/index.js", "--db-path", "/path/to/your/lancedb/storage" ] } } }

用您的实际安装路径替换路径:

  • /path/to/lancedb-node/dist/index.js - 已编译 index.js 文件的路径
  • /path/to/your/lancedb/storage - 您的 LanceDB 存储目录的路径

自定义嵌入函数

该项目包括一个自定义的OllamaEmbeddingFunction ,它:

  • 向 Ollama API 发送文本
  • 接收 768 维的嵌入
  • 格式化它们以便与 LanceDB 一起使用

向量搜索示例

该示例在“ai-rag”表中搜索“如何定义成功标准”,并显示其相似度分数的结果。

执照

MIT 许可证

贡献

欢迎贡献代码!欢迎提交 Pull 请求。

-
security - not tested
F
license - not found
-
quality - not tested

hybrid server

The server is able to function both locally and remotely, depending on the configuration or use case.

使用 LanceDB 和 Ollama 的嵌入模型进行向量搜索的 Node.js 实现。

  1. 概述
    1. 先决条件
      1. 安装
        1. 依赖项
          1. 用法
            1. 配置
              1. MCP 配置
                1. 自定义嵌入函数
                  1. 向量搜索示例
                    1. 执照
                      1. 贡献

                        Related MCP Servers

                        • -
                          security
                          A
                          license
                          -
                          quality
                          Provides RAG capabilities for semantic document search using Qdrant vector database and Ollama/OpenAI embeddings, allowing users to add, search, list, and delete documentation with metadata support.
                          Last updated -
                          5
                          4
                          TypeScript
                          Apache 2.0
                        • -
                          security
                          A
                          license
                          -
                          quality
                          A server that provides data retrieval capabilities powered by Chroma embedding database, enabling AI models to create collections over generated data and user inputs, and retrieve that data using vector search, full text search, and metadata filtering.
                          Last updated -
                          157
                          Python
                          Apache 2.0
                        • -
                          security
                          A
                          license
                          -
                          quality
                          A Model Context Protocol server that enables semantic search capabilities by providing tools to manage Qdrant vector database collections, process and embed documents using various embedding services, and perform semantic searches across vector embeddings.
                          Last updated -
                          89
                          TypeScript
                          MIT License
                        • -
                          security
                          A
                          license
                          -
                          quality
                          Enables semantic search across multiple Qdrant vector database collections, supporting multi-query capability and providing semantically relevant document retrieval with configurable result counts.
                          Last updated -
                          46
                          TypeScript
                          MIT License

                        View all related MCP servers

                        MCP directory API

                        We provide all the information about MCP servers via our MCP API.

                        curl -X GET 'https://glama.ai/api/mcp/v1/servers/vurtnec/mcp-LanceDB-node'

                        If you have feedback or need assistance with the MCP directory API, please join our Discord server