Skip to content

Commit 99b2359

Browse files
committed
add blog article about playground
1 parent b1e211a commit 99b2359

File tree

3 files changed

+122
-0
lines changed

3 files changed

+122
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
---
2+
title: "Introducing the MongoDB-RAG Playground"
3+
author: Michael Lynn
4+
author_title: Developer Advocate @ MongoDB
5+
author_url: https://github.com/mrlynn
6+
author_image_url: https://avatars.githubusercontent.com/u/192552?v=4
7+
tags: [mongodb, vector-search, rag, ai, workshop, tutorial]
8+
---
9+
# Introducing the MongoDB-RAG Playground: A Developer's Guide to Vector Search
10+
11+
## 🚀 What is the MongoDB-RAG Playground?
12+
13+
The **MongoDB-RAG Playground** is an interactive UI built directly into the `mongodb-rag` library. Designed to provide developers with a **quick and easy** way to explore **vector search**, the Playground helps users visualize their documents, manage indexes, and run search queries—all without writing extra code.
14+
15+
Once a developer has set up their MongoDB Atlas cluster and ingested data, they can launch the Playground with a single command:
16+
17+
```sh
18+
npx mongodb-rag playground
19+
```
20+
21+
This command spins up a UI where developers can **view documents**, **manage vector indexes**, and **perform vector searches**, making it a powerful tool for experimentation and debugging.
22+
23+
---
24+
25+
## 🔧 Getting Started with the Playground
26+
27+
To take full advantage of the Playground, follow these steps:
28+
29+
### 1️⃣ Initialize MongoDB-RAG
30+
First, install the `mongodb-rag` package if you haven’t already:
31+
32+
```sh
33+
npm install mongodb-rag dotenv
34+
```
35+
36+
Then, initialize a configuration file:
37+
38+
```sh
39+
npx mongodb-rag init
40+
```
41+
42+
This will generate a `.mongodb-rag.json` file where you can specify your **MongoDB connection string**, database name, and collection name.
43+
44+
### 2️⃣ Ingest Data
45+
Before running vector search, you need to ingest documents. This can be done using:
46+
47+
```sh
48+
npx mongodb-rag ingest --file data.json
49+
```
50+
51+
or by uploading a document directly from the Playground UI.
52+
53+
### 3️⃣ Create a Vector Search Index
54+
Once the data is loaded, create an **Atlas Vector Search Index** using:
55+
56+
```sh
57+
npx mongodb-rag create-index
58+
```
59+
60+
Alternatively, you can manage indexes from within the Playground UI.
61+
62+
### 4️⃣ Launch the Playground
63+
With the dataset and vector index in place, start the Playground:
64+
65+
```sh
66+
npx mongodb-rag playground
67+
```
68+
69+
This command launches a **local UI**, allowing you to explore your data in real time.
70+
71+
---
72+
73+
## 🖥️ Features of the Playground
74+
75+
### 📂 Document Viewer
76+
- Browse your stored documents with ease.
77+
- Quickly inspect metadata, embeddings, and content.
78+
79+
### 🔍 Search Panel
80+
- Run **vector search queries** directly from the UI.
81+
- Experiment with different similarity metrics (cosine, dot-product, Euclidean).
82+
83+
### ⚙️ Index Management
84+
- View existing indexes.
85+
- Create new **vector search indexes**.
86+
- Configure embedding models and dimensions.
87+
88+
### 📡 Live Updates
89+
- Real-time indexing and search updates via **WebSockets**.
90+
- Instant feedback on configuration changes.
91+
92+
---
93+
94+
## 🔥 Why Use the Playground?
95+
96+
- **No need to build a frontend** – The Playground provides an out-of-the-box UI for MongoDB vector search.
97+
- **Debugging made easy** – Quickly inspect documents and indexes without writing queries manually.
98+
- **Seamless experimentation** – Tweak search parameters and embeddings dynamically.
99+
100+
---
101+
102+
## 🎯 Try It Today
103+
The **MongoDB-RAG Playground** is the fastest way to interact with **MongoDB Atlas Vector Search**. Whether you're building an **AI-powered search** engine or testing **RAG (Retrieval-Augmented Generation)** workflows, the Playground gives you full control over your data and indexes in a simple UI.
104+
105+
Ready to get started?
106+
107+
Run:
108+
109+
```sh
110+
npx mongodb-rag playground
111+
```
112+
113+
And start exploring the power of **MongoDB Vector Search** today! 🚀
114+

src/core/MongoRAG.js

+7
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,9 @@ class MongoRAG {
152152
dimensions: this.config.embedding.dimensions
153153
});
154154

155+
// Ensure the index is created
156+
await indexManager.ensureIndex();
157+
155158
// Construct the vector search query using the $vectorSearch operator
156159
const aggregation = query
157160
? [{
@@ -167,9 +170,13 @@ class MongoRAG {
167170
}]
168171
: [{ $skip: skip }, { $limit: maxResults }]; // Simple aggregation for all documents
169172

173+
console.log('[DEBUG] Aggregation query:', JSON.stringify(aggregation, null, 2));
174+
170175
log(`Running vector search in ${database || this.config.defaultDatabase}.${collection || this.config.defaultCollection}`);
171176
const results = await col.aggregate(aggregation).toArray();
172177

178+
console.log('[DEBUG] Search results:', results);
179+
173180
return results.map(r => ({
174181
content: r.content,
175182
documentId: r.documentId,

src/playground-ui/src/App.js

+1
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,7 @@ function App() {
171171

172172
setSearching(true);
173173
try {
174+
console.log("Searching for:", query);
174175
const response = await fetch(`${BACKEND_URL}/api/search`, {
175176
method: 'POST',
176177
headers: { 'Content-Type': 'application/json' },

0 commit comments

Comments
 (0)