Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/docs.json
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@
"integrations/vector-db-integrations/chromadb",
"integrations/vector-db-integrations/couchbase",
"integrations/vector-db-integrations/milvus",
"integrations/vector-db-integrations/moss",
"integrations/vector-db-integrations/pgvector",
"integrations/vector-db-integrations/pinecone",
"integrations/vector-db-integrations/weaviate"
Expand Down
117 changes: 117 additions & 0 deletions docs/integrations/vector-db-integrations/moss.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
---
title: Moss
sidebarTitle: Moss
---

In this section, we present how to connect Moss to MindsDB.

[Moss](https://moss.dev) is a semantic search runtime for Conversational AI agents. It delivers hybrid search with sub-10ms latency.

## Prerequisites

Before proceeding, ensure the following prerequisites are met:

1. Install MindsDB locally via [Docker](/setup/self-hosted/docker) or [Docker Desktop](/setup/self-hosted/docker-desktop).
2. To connect Moss to MindsDB, install the required dependencies following [this instruction](/setup/self-hosted/docker#install-dependencies).
3. Create a Moss account and obtain your project credentials from [portal.usemoss.dev](https://portal.usemoss.dev).

## Connection

This handler is implemented using the `moss` Python library.

To connect Moss to MindsDB, use the following statement:

```sql
CREATE DATABASE moss_db
WITH ENGINE = 'moss',
PARAMETERS = {
"project_id": "your-project-id",
"project_key": "moss_access_key_xxxxx",
"alpha": "0.8"
};
```

The required parameters are:

- `project_id`: Your Moss project ID, available from [portal.usemoss.dev](https://portal.usemoss.dev).
- `project_key`: Your Moss project key (secret), available from [portal.usemoss.dev](https://portal.usemoss.dev).

The optional parameters are:

- `alpha`: Hybrid search weight between `0.0` (keyword-only) and `1.0` (semantic-only). Defaults to `0.8`.

## Usage

### Inserting documents

Insert documents to create a new index. The index is built asynchronously — MindsDB waits until it is ready before returning (typically 5–30 seconds).

```sql
INSERT INTO moss_db.my_index (id, content, metadata)
VALUES
('doc-1', 'MindsDB unifies AI and data with SQL', '{"category": "mindsdb"}'),
('doc-2', 'Moss delivers sub-10ms hybrid semantic search', '{"category": "moss"}'),
('doc-3', 'RAG pipelines combine retrieval and generation', '{"category": "rag"}');
```

<Note>
The `id` column is optional. If omitted, Moss generates a unique ID
automatically using a hash of the document content.
</Note>

Inserting into an existing index upserts the documents:

```sql
INSERT INTO moss_db.my_index (id, content, metadata)
VALUES ('doc-4', 'Vector databases store embeddings for similarity search', '{"category": "vectordb"}');
```

### Semantic search

Query your index using natural language. Results are ranked by relevance and include a `distance` column (lower = better match):

```sql
SELECT id, content, distance
FROM moss_db.my_index
WHERE content = 'how do I build a RAG pipeline?'
LIMIT 5;
```

### Fetch all documents

```sql
SELECT id, content, metadata
FROM moss_db.my_index;
```

### Fetch by ID

```sql
SELECT id, content
FROM moss_db.my_index
WHERE id = 'doc-1';
```

### Semantic search with metadata filter

Combine a semantic search query with a metadata filter:

```sql
SELECT id, content, distance
FROM moss_db.my_index
WHERE content = 'semantic search performance'
AND metadata.category = 'moss'
LIMIT 3;
```

### Delete a document

```sql
DELETE FROM moss_db.my_index WHERE id = 'doc-1';
```

### Drop an index

```sql
DROP TABLE moss_db.my_index;
```
118 changes: 118 additions & 0 deletions mindsdb/integrations/handlers/moss_handler/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
---
title: Moss
sidebarTitle: Moss
---

In this section, we present how to connect Moss to MindsDB.

[Moss](https://moss.dev) is a semantic search runtime built for Conversational AI agents. It lets you index documents and run hybrid semantic/keyword queries in under 10ms — fast enough for real-time conversation, compared to 200–300ms with typical retrieval systems.

## Prerequisites

Before proceeding, ensure the following prerequisites are met:

1. Install MindsDB locally via [Docker](/setup/self-hosted/docker) or [Docker Desktop](/setup/self-hosted/docker-desktop).
2. To connect Moss to MindsDB, install the required dependencies following [this instruction](/setup/self-hosted/docker#install-dependencies).
3. Create a Moss project and obtain your credentials from the [Moss Portal](https://portal.usemoss.dev).

## Connection

This handler is implemented using the `moss` Python library.

To connect your Moss project to MindsDB, use the following statement:

```sql
CREATE DATABASE moss_datasource
WITH ENGINE = 'moss',
PARAMETERS = {
"project_id": "your-project-id",
"project_key": "moss_access_key_xxxxx",
"alpha": "0.8"
};
```

The required parameters are:

* `project_id`: Your Moss project ID, available in the [Moss Portal](https://portal.usemoss.dev).
* `project_key`: Your Moss project access key.

The optional parameters are:

* `alpha`: Controls the blend between semantic and keyword search. Range is `0.0` to `1.0`, where `0.0` is pure keyword (BM25), `1.0` is pure semantic, and `0.8` is the default.

## Usage

Once connected, you can insert documents into a Moss index. The index is created automatically on the first insert.

```sql
INSERT INTO moss_datasource.my_index (id, content, metadata)
VALUES
('doc-1', 'MindsDB unifies AI and data pipelines', '{"category": "product"}'),
('doc-2', 'Connect MindsDB to PostgreSQL, MySQL, and more', '{"category": "integrations"}'),
('doc-3', 'Create AI models using the CREATE MODEL syntax', '{"category": "docs"}');
```

<Note>
The `INSERT` statement blocks until Moss finishes building the index, which typically takes 5–30 seconds depending on document count.
</Note>

To run a semantic search query:

```sql
SELECT id, content, distance
FROM moss_datasource.my_index
WHERE content = 'how do I create an AI model?'
LIMIT 5;
```

The `distance` column is `1 - score`, so lower values indicate a closer match.

To fetch all documents without a search query:

```sql
SELECT id, content, metadata
FROM moss_datasource.my_index;
```

To fetch specific documents by ID:

```sql
SELECT id, content
FROM moss_datasource.my_index
WHERE id = 'doc-1';
```

To filter results by metadata alongside a semantic search:

```sql
SELECT id, content, distance
FROM moss_datasource.my_index
WHERE content = 'connecting to databases'
AND metadata.category = 'integrations'
LIMIT 3;
```

To delete documents from an index:

```sql
DELETE FROM moss_datasource.my_index
WHERE id = 'doc-1';
```

To drop an index entirely:

```sql
DROP TABLE moss_datasource.my_index;
```

## Using Moss in a RAG Pipeline

You can combine Moss with a MindsDB model to build a retrieval-augmented generation (RAG) pipeline entirely in SQL:

```sql
SELECT r.content, m.answer
FROM moss_datasource.my_index AS r
JOIN mindsdb.my_llm AS m
WHERE r.content = 'what is the refund policy?'
LIMIT 1;
```
9 changes: 9 additions & 0 deletions mindsdb/integrations/handlers/moss_handler/__about__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
__title__ = "MindsDB Moss handler"
__package_name__ = "mindsdb_moss_handler"
__version__ = "0.0.1"
__description__ = "MindsDB handler for Moss semantic search"
__author__ = "Keshav Arora"
__github__ = "https://github.com/mindsdb/mindsdb"
__pypi__ = "https://pypi.org/project/mindsdb/"
__license__ = "MIT"
__copyright__ = "Copyright 2024 - mindsdb"
33 changes: 33 additions & 0 deletions mindsdb/integrations/handlers/moss_handler/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
from mindsdb.integrations.libs.const import HANDLER_SUPPORT_LEVEL, HANDLER_TYPE

from .__about__ import __description__ as description
from .__about__ import __version__ as version
from .connection_args import connection_args, connection_args_example

try:
from .moss_handler import MossHandler as Handler

import_error = None
except Exception as e:
Handler = None
import_error = e

title = "Moss"
name = "moss"
type = HANDLER_TYPE.DATA
support_level = HANDLER_SUPPORT_LEVEL.COMMUNITY
icon_path = "icon.png"

__all__ = [
"Handler",
"version",
"name",
"type",
"title",
"description",
"support_level",
"connection_args",
"connection_args_example",
"import_error",
"icon_path",
]
31 changes: 31 additions & 0 deletions mindsdb/integrations/handlers/moss_handler/connection_args.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
from collections import OrderedDict

from mindsdb.integrations.libs.const import HANDLER_CONNECTION_ARG_TYPE as ARG_TYPE

connection_args = OrderedDict(
project_id={
"type": ARG_TYPE.STR,
"description": "Moss project ID from the Moss Portal (portal.usemoss.dev)",
"required": True,
},
project_key={
"type": ARG_TYPE.PWD,
"description": "Moss project key from the Moss Portal",
"required": True,
"secret": True,
},
alpha={
"type": ARG_TYPE.STR,
"description": (
"Hybrid search weight between semantic and keyword search. "
"0.0 = pure keyword (BM25), 1.0 = pure semantic, 0.8 = default"
),
"required": False,
},
)

connection_args_example = OrderedDict(
project_id="your-project-id",
project_key="moss_access_key_xxxxx",
alpha="0.8",
)
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading