Skip to content

Commit 17b9ade

Browse files
committed
Polish
1 parent 910c5fb commit 17b9ade

File tree

1 file changed

+24
-29
lines changed

1 file changed

+24
-29
lines changed

src/oss/javascript/integrations/vectorstores/couchbase_query.mdx

Lines changed: 24 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,17 @@
22
title: Couchbase Query Vector Store
33
---
44

5-
The `CouchbaseQueryVectorStore` is an implementation of Vector Search that uses the [Query Service](https://docs.couchbase.com/server/current/learn/services-and-indexes/services/query-service.html) (SQL++) and [Index Service](https://docs.couchbase.com/server/current/learn/services-and-indexes/services/index-service.html) for vector similarity search instead of the Search service. This provides an alternative approach for vector operations using SQL++ queries with vector functions.
5+
The `CouchbaseQueryVectorStore` is the preferred implementation of Vector Search in Couchbase. It uses the [Query Service](https://docs.couchbase.com/server/current/learn/services-and-indexes/services/query-service.html) (SQL++) and [Index Service](https://docs.couchbase.com/server/current/learn/services-and-indexes/services/index-service.html) for vector similarity search, instead of the Search service. This provides a more powerful and straightforward approach for vector operations using SQL++ queries with vector functions.
66

77
More information about Couchbase's vector search capabilities can be found in the official documentation: [Choose the Right Vector Index](https://docs.couchbase.com/server/current/vector-index/use-vector-indexes.html).
88

9-
<Note>
10-
This functionality is only available in Couchbase Server 8.0 and above, which introduced vector search capabilities in the Query service.
11-
</Note>
9+
<Warning>
10+
This functionality is only available in Couchbase Server 8.0 and above.
11+
</Warning>
1212

13-
## Key Differences from CouchbaseVectorStore
13+
## Key Differences from `CouchbaseSearchVectorStore` (formerly `CouchbaseVectorStore`)
1414

15-
- **Query Service**: Uses Couchbase's Query service with SQL++ instead of the Search service
15+
- **Query and Index Service**: Uses Couchbase's Query service with SQL++ instead of the Search service
1616
- **No Index Required**: Does not require a pre-configured search index for basic operations
1717
- **SQL++ Syntax**: Supports WHERE clauses and SQL++ query syntax for filtering
1818
- **Vector Functions**: Uses `APPROX_VECTOR_DISTANCE` function for similarity calculations
@@ -26,15 +26,15 @@ npm install couchbase @langchain/openai @langchain/community @langchain/core
2626

2727
## Create Couchbase Connection Object
2828

29-
We create a connection to the Couchbase cluster initially and then pass the cluster object to the Vector Store. Here, we are connecting using the username and password.
30-
You can also connect using any other supported way to your cluster.
29+
We create a connection to the Couchbase cluster and then pass the cluster object to the Vector Store. Here, we are connecting using the username and password.
30+
You can also connect to your cluster using any other supported method.
3131

3232
For more information on connecting to the Couchbase cluster, please check the [Node SDK documentation](https://docs.couchbase.com/nodejs-sdk/current/hello-world/start-using-sdk.html#connect).
3333

3434
```typescript
3535
import { Cluster } from "couchbase";
3636

37-
const connectionString = "couchbase://localhost"; // or couchbases://localhost if you are using TLS
37+
const connectionString = "couchbase://localhost";
3838
const dbUsername = "Administrator"; // valid database user with read access to the bucket being queried
3939
const dbPassword = "Password"; // password for the database user
4040

@@ -67,7 +67,7 @@ const vectorStore = await CouchbaseQueryVectorStore.initialize(embeddings, {
6767
bucketName: "my-bucket",
6868
scopeName: "my-scope",
6969
collectionName: "my-collection",
70-
textKey: "text", // optional, defaults to "text"
70+
textKey: "text", // optional, defaults to "text"
7171
embeddingKey: "embedding", // optional, defaults to "embedding"
7272
distanceStrategy: DistanceStrategy.COSINE, // optional, defaults to DOT
7373
});
@@ -77,7 +77,7 @@ const vectorStore = await CouchbaseQueryVectorStore.initialize(embeddings, {
7777

7878
The Query vector store supports creating vector indexes to improve search performance. There are two types of indexes available:
7979

80-
### HYPERSCALE Index
80+
### Hyperscale Index
8181
A specialized vector index optimized for vector operations using Couchbase's vector indexing capabilities:
8282

8383
```typescript
@@ -129,7 +129,7 @@ WITH {'dimension': 1536, 'similarity': 'dot', 'description': 'IVF1024,SQ8', 'sca
129129

130130
### Key Differences
131131

132-
| Aspect | HYPERSCALE Index | COMPOSITE Index |
132+
| Aspect | Hyperscale Index | Composite Index |
133133
|--------|-------------|-----------------|
134134
| **SQL++ Syntax** | `CREATE VECTOR INDEX` | `CREATE INDEX` |
135135
| **Vector Field** | `(field VECTOR)` with `INCLUDE` clause | `(field1, field2, vector_field VECTOR)` |
@@ -321,13 +321,10 @@ await vectorStore.delete({ ids: documentIds });
321321

322322
1. **Create Indexes**: Use `createIndex()` to create appropriate vector indexes for better performance
323323
2. **Choose Index Type**:
324-
- Use **HYPERSCALE indexes** for pure vector search workloads where you primarily perform similarity searches
325-
- Use **COMPOSITE indexes** for mixed queries that combine vector similarity with scalar field filtering
324+
- Use **Hyperscale indexes** for pure vector search workloads where you primarily perform similarity searches
325+
- Use **Composite indexes** for mixed queries that combine vector similarity with scalar field filtering
326326
3. **Tune Parameters**: Adjust `indexScanNprobes` and `indexTrainlist` based on your data size and performance requirements
327327
4. **Filter Early**: Use WHERE clauses to reduce the search space before vector calculations
328-
5. **Index Strategy**:
329-
- **HYPERSCALE**: Better for high-performance vector similarity search with minimal scalar filtering
330-
- **COMPOSITE**: Better when you frequently filter by both vector similarity and scalar fields in the same query
331328

332329
## Error Handling
333330

@@ -351,9 +348,9 @@ If you see errors related to insufficient training data, you may need to:
351348
- For collections with < 1 million vectors, use `number_of_vectors / 1000` for centroids
352349
- For larger collections, use `sqrt(number_of_vectors)` for centroids
353350

354-
## Comparison with CouchbaseVectorStore
351+
## Comparison with `CouchbaseSearchVectorStore`
355352

356-
| Feature | CouchbaseQueryVectorStore | CouchbaseVectorStore |
353+
| Feature | `CouchbaseQueryVectorStore` | `CouchbaseSearchVectorStore` |
357354
|---------|---------------------------|----------------------|
358355
| Service | Query (SQL++) | Search (FTS) |
359356
| Index Required | Optional (for performance) | Required |
@@ -362,21 +359,19 @@ If you see errors related to insufficient training data, you may need to:
362359
| Setup Complexity | Lower | Higher |
363360
| Performance | Good with indexes | Optimized for search |
364361

365-
<br />
366-
<br />
362+
## Frequently Asked Questions
367363

368-
# Frequently Asked Questions
364+
### Do I need to create an index before using `CouchbaseQueryVectorStore`?
369365

370-
## Question: Do I need to create an index before using CouchbaseQueryVectorStore?
366+
No, unlike the Search-based `CouchbaseSearchVectorStore`, the Query-based implementation can work without pre-created indexes. However, creating appropriate vector indexes (Hyperscale or Composite) will significantly improve query performance.
371367

372-
No, unlike the Search-based CouchbaseVectorStore, the Query-based implementation can work without pre-created indexes. However, creating appropriate vector indexes (HYPERSCALE or COMPOSITE) will significantly improve query performance.
368+
### When should I use Hyperscale vs. Composite indexes?
373369

374-
## Question: When should I use HYPERSCALE vs COMPOSITE indexes?
370+
- Use **Hyperscale indexes** when you primarily perform vector similarity searches with minimal filtering on other fields
371+
- Use **Composite indexes** when you frequently combine vector similarity with filtering on scalar fields in the same query
372+
- Learn more about how to [Choose the Right Vector Index](https://docs.couchbase.com/server/current/vector-index/use-vector-indexes.html)
375373

376-
- Use **HYPERSCALE indexes** when you primarily perform vector similarity searches with minimal filtering on other fields
377-
- Use **COMPOSITE indexes** when you frequently combine vector similarity with filtering on scalar fields in the same query
378-
379-
## Question: Can I use both CouchbaseVectorStore and CouchbaseQueryVectorStore on the same data?
374+
### Can I use both `CouchbaseQueryVectorStore` and `CouchbaseSearchVectorStore` on the same data?
380375

381376
Yes, both can work on the same document structure. However, they use different services (Search vs Query) and have different indexing requirements.
382377

0 commit comments

Comments
 (0)