Skip to content

Commit 5be7ae5

Browse files
Merge pull request #1 from couchbase-examples/minor-changes
minor updates
2 parents 644ec04 + 02d547e commit 5be7ae5

File tree

2 files changed

+44
-35
lines changed

2 files changed

+44
-35
lines changed

CouchbaseVectorSearchDemo/Program.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,6 @@ private static async Task<VectorStoreCollection<string, Glossary>> GetCouchbaseV
247247
// Configure Hyperscale index options
248248
var collectionOptions = new CouchbaseQueryCollectionOptions
249249
{
250-
IndexName = "hyperscale_glossary_index",
251250
SimilarityMetric = "cosine"
252251
};
253252

CouchbaseVectorSearchDemo/README.md

Lines changed: 44 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -4,47 +4,48 @@ A quickstart example demonstrating vector search with Couchbase and Microsoft Se
44

55
## Introduction
66

7-
This demo showcases the **[Semantic Kernel Couchbase connector](https://github.com/Couchbase-Ecosystem/couchbase-semantic-kernel)** - a .NET library that bridges Microsoft's Semantic Kernel framework with Couchbase's vector search capabilities. The connector provides a seamless integration that allows developers to build AI-powered applications using familiar Semantic Kernel abstractions while leveraging Couchbase's vector indexing for high-performance semantic search.
7+
This demo showcases the **Semantic Kernel Couchbase connector** - a .NET library that bridges Microsoft's Semantic Kernel framework with Couchbase's vector search capabilities. The connector provides a seamless integration that allows developers to build AI-powered applications using familiar Semantic Kernel abstractions while leveraging Couchbase's vector indexing for high-performance semantic search.
88

99
The connector supports three index types:
1010
- **Hyperscale Vector Index** - for pure vector search at scale ← *Used in this demo*
1111
- **Composite Vector Index** - for vector search with heavy scalar filtering
12-
- **FTS** (Full-Text Search) - for hybrid text + semantic search
12+
- **Search Vector Index** (using Search service) - for hybrid text + semantic search
1313

1414
This makes the connector ideal for RAG (Retrieval-Augmented Generation) applications, semantic search engines, hybrid search, and recommendation systems.
1515

1616
## Prerequisites
1717

18-
### 1. Couchbase Server Setup
18+
### Couchbase Server Setup
1919
- **Couchbase Server 8.0+**
2020
- Local installation or Couchbase Cloud/Capella
2121
- Bucket with proper read/write permissions
2222
- Query service enabled for SQL++ operations
2323

24-
### 2. OpenAI API Access
24+
### OpenAI API Access
2525
- **OpenAI API Key** - Get one from: https://platform.openai.com/api-keys
2626
- Used for generating text embeddings with `text-embedding-3-small` model
2727
- Ensure you have sufficient API quota for embedding generation
2828

29-
### 3. Development Environment
29+
### Development Environment
3030
- **.NET 8.0** or later
3131
- Visual Studio, VS Code, or JetBrains Rider
3232
- Basic understanding of C# and vector databases
3333

34-
## Quick Start
3534

36-
### 1. Clone and Navigate
35+
## Setting Up the Environment
36+
37+
### Clone and Navigate
3738
```bash
3839
git clone https://github.com/couchbase-examples/couchbase-semantic-kernel-quickstart.git
3940
cd couchbase-semantic-kernel-quickstart/CouchbaseVectorSearchDemo
4041
```
4142

42-
### 2. Install Dependencies
43+
### Install Dependencies
4344
```bash
4445
dotnet restore
4546
```
4647

47-
### 3. Configuration Setup
48+
### Configuration Setup
4849

4950
Update `appsettings.Development.json` with your credentials:
5051

@@ -65,17 +66,7 @@ Update `appsettings.Development.json` with your credentials:
6566
}
6667
```
6768

68-
### 4. Prepare Couchbase
69-
70-
Ensure you have the bucket, scope, and collection ready in Couchbase:
71-
- **Bucket**: `demo`
72-
- **Scope**: `semantic-kernel`
73-
- **Collection**: `glossary`
74-
75-
### 5. Run the Application
76-
```bash
77-
dotnet run
78-
```
69+
> **Note**: The `BucketName`, `ScopeName`, and `CollectionName` values can be changed to match your Couchbase setup, but you'll need to update the corresponding code references in the demo application accordingly.
7970
8071
## Understanding the Data Model
8172

@@ -107,7 +98,14 @@ internal sealed class Glossary
10798

10899
## Step-by-Step Tutorial
109100

110-
### Step 1: Data Ingestion and Embedding Generation
101+
### Prepare Couchbase
102+
103+
Ensure you have the bucket, scope, and collection ready in Couchbase:
104+
- **Bucket**: `demo`
105+
- **Scope**: `semantic-kernel`
106+
- **Collection**: `glossary`
107+
108+
### Data Ingestion and Embedding Generation
111109

112110
This step demonstrates how the connector works with Semantic Kernel's vector store abstractions:
113111

@@ -118,13 +116,12 @@ var collection = vectorStore.GetCollection<string, Glossary>(
118116
"glossary",
119117
new CouchbaseQueryCollectionOptions
120118
{
121-
IndexName = "hyperscale_glossary_index", // Hyperscale index name
122119
SimilarityMetric = "cosine"
123120
}
124121
);
125122
```
126123

127-
The `CouchbaseQueryCollectionOptions` works with both Hyperscale and Composite indexes - simply specify the appropriate index name. For FTS indexes, use `CouchbaseSearchCollection` with `CouchbaseSearchCollectionOptions` instead.
124+
The `CouchbaseQueryCollectionOptions` works with both Hyperscale and Composite indexes. For Search Vector indexes, use `CouchbaseSearchCollection` with `CouchbaseSearchCollectionOptions` instead.
128125

129126
**Automatic Embedding Generation** - The connector integrates with Semantic Kernel's `IEmbeddingGenerator` interface to automatically generate embeddings from text. When you provide an embedding generator (in this case, OpenAI's `text-embedding-3-small`), the text is automatically converted to vectors:
130127

@@ -144,7 +141,6 @@ await collection.UpsertAsync(glossaryEntries);
144141
This creates 6 sample glossary entries with technical terms, generates embeddings for each definition, and stores them in Couchbase with the following structure:
145142

146143
**Document ID:** `"1"` (from Key field)
147-
148144
**Document Content:**
149145
```json
150146
{
@@ -155,9 +151,13 @@ This creates 6 sample glossary entries with technical terms, generates embedding
155151
}
156152
```
157153

158-
### Step 2: Hyperscale Index Creation
154+
### Hyperscale Index Creation
159155

160-
This demo uses a **Hyperscale Vector Index** - optimized for pure vector searches without heavy scalar filtering. After documents are inserted, the demo creates the Hyperscale index:
156+
While the application works without creating indexes manually, you can optionally create a vector index for better performance.
157+
158+
This demo uses a **Hyperscale Vector Index** - optimized for pure vector searches without heavy scalar filtering.
159+
160+
After documents are inserted, the demo creates the Hyperscale index:
161161

162162
```sql
163163
CREATE VECTOR INDEX `hyperscale_glossary_index`
@@ -177,9 +177,9 @@ USING GSI WITH {
177177
- **Include Fields**: Non-vector fields for faster retrieval
178178
- **Quantization**: `IVF,SQ8` (Inverted File with 8-bit scalar quantization)
179179

180-
> **Note**: Composite vector indexes can be created similarly by adding scalar fields to the index definition. Use Composite indexes when your queries frequently filter on scalar values before vector comparison. For this demo, we use Hyperscale since we're demonstrating pure semantic search capabilities.
180+
> **Note**: [Composite vector indexes](https://docs.couchbase.com/server/current/vector-index/composite-vector-index.html) can be created similarly by adding scalar fields to the index definition. Use Composite indexes when your queries frequently filter on scalar values before vector comparison. For this demo, we use Hyperscale since we are demonstrating pure semantic search capabilities.
181181
182-
### Step 3: Vector Search Operations
182+
### Vector Search Operations
183183

184184
The demo performs two types of searches using the connector's `SearchAsync()` method with the Hyperscale index:
185185

@@ -205,6 +205,8 @@ ORDER BY _distance ASC
205205
LIMIT 1
206206
```
207207

208+
> **Note**: The distance metric (`'cosine'` in this example) comes from the `SimilarityMetric` property configured when creating the collection:
209+
208210
**Expected Result**: Finds "API" entry with high similarity
209211

210212
#### Filtered Vector Search
@@ -248,7 +250,7 @@ Couchbase offers three types of vector indexes optimized for different use cases
248250
- Designed to scale to billions of vectors with low memory footprint
249251
- Optimized for high-performance concurrent operations
250252
- Ideal for: Large-scale semantic search, recommendations, content discovery
251-
- **Creation**: Using SQL++ `CREATE VECTOR INDEX` as shown in Step 2
253+
- **Creation**: Using SQL++ `CREATE VECTOR INDEX` as shown in the Hyperscale Index Creation section
252254

253255
**2. Composite Vector Indexes**
254256
- Uses SQL++ queries via `CouchbaseQueryCollection`
@@ -257,22 +259,24 @@ Couchbase offers three types of vector indexes optimized for different use cases
257259
- Ideal for: Compliance filtering, user-specific searches, time-bounded queries
258260
- **Creation**: Similar to Hyperscale but includes scalar fields in the index definition
259261

260-
**3. FTS (Full-Text Search) Indexes**
262+
**3. Search Vector Indexes**
261263
- Uses Couchbase Search API via `CouchbaseSearchCollection`
262264
- Best for hybrid search scenarios combining full-text search with vector similarity
263265
- Supports text search, faceting, and vector search in a single query
264266
- Ideal for: Hybrid search, text + semantic search, moderate scale deployments
265267
- **Creation**: Using Search Service index configuration with vector field support
266268

269+
267270
All three index types work with the same Semantic Kernel abstractions (`SearchAsync()`, `UpsertAsync()`, etc.). The main difference is which collection class you instantiate and the underlying query engine.
268271

269272
**Choosing the Right Type**:
270273
- Start with **Hyperscale** for pure vector searches and large datasets
271274
- Use **Composite** when scalar filters eliminate large portions of data before vector comparison
272-
- Use **FTS** when you need hybrid search combining full-text and semantic search
275+
- Use **Search Vector Index** when you need hybrid search combining full-text and semantic search
273276

274277
For more details, see the [Couchbase Vector Index Documentation](https://docs.couchbase.com/server/current/vector-index/use-vector-indexes.html).
275278

279+
276280
### Index Configuration (Couchbase 8.0+)
277281

278282
The `description` parameter in the index definition controls vector storage optimization through centroids and quantization:
@@ -298,6 +302,12 @@ For detailed configuration options, see the [Quantization & Centroid Settings](h
298302

299303
## Running the Demo
300304

305+
### Build and Execute
306+
```bash
307+
dotnet build
308+
dotnet run
309+
```
310+
301311
### Expected Output
302312
```
303313
Couchbase Hyperscale Vector Search Demo
@@ -308,7 +318,7 @@ Data ingestion completed
308318
309319
Step 2: Creating Hyperscale vector index manually...
310320
Executing Hyperscale index creation query...
311-
Hyperscale vector index 'hyperscale_glossary_index' already exists.
321+
Hyperscale vector index 'hyperscale_glossary_index' created successfully!
312322
313323
Step 3: Performing vector search...
314324
Found: API
@@ -341,7 +351,7 @@ The Couchbase Semantic Kernel connector provides a seamless integration between
341351
**Vector Store Classes:**
342352
- **`CouchbaseVectorStore`** - Main entry point for vector store operations
343353
- **`CouchbaseQueryCollection`** - Collection class for Hyperscale and Composite indexes (SQL++)
344-
- **`CouchbaseSearchCollection`** - Collection class for FTS indexes (Search API)
354+
- **`CouchbaseSearchCollection`** - Collection class for Search Vector indexes (Search, formerly known as Full Text service)
345355

346356
**Common Methods (all index types):**
347357
- **`GetCollection<TKey, TRecord>()`** - Returns a typed collection for CRUD operations
@@ -351,7 +361,7 @@ The Couchbase Semantic Kernel connector provides a seamless integration between
351361

352362
**Configuration Options:**
353363
- **`CouchbaseQueryCollectionOptions`** - For Hyperscale and Composite indexes
354-
- **`CouchbaseSearchCollectionOptions`** - For FTS indexes
364+
- **`CouchbaseSearchCollectionOptions`** - For Search Vector indexes
355365

356366
## Learn More
357367

0 commit comments

Comments
 (0)