Skip to content

Commit d5647ff

Browse files
committed
add Semantic Search doc and other docs improvements
1 parent 161b2e6 commit d5647ff

File tree

14 files changed

+133
-26
lines changed

14 files changed

+133
-26
lines changed

docs/docs/concepts/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
title: Concepts
33
description: Understand the core concepts behind SharpVector, from vector similarity to embedding strategies and in-memory architecture.
44
---
5-
# Concepts
5+
# :octicons-light-bulb-24: Concepts
66

77
## What is a Vector Database?
88

docs/docs/embeddings/index.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
# Embeddings
1+
---
2+
title: Embeddings
3+
---
4+
# :fontawesome-solid-square-binary: Embeddings
25

36
`Build5Nines.SharpVector` includes the following support for using AI Models to generate the text embeddings for the vector database instead of generating them locally. The use of an AI Embeddings model can greatly increase the quality of the semantic search.
47

docs/docs/get-started/data-management/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
title: Data Management
33

44
---
5-
# Data Management
5+
# :material-database-edit-outline: Data Management
66

77
Since `Build5Nines.SharpVector` is a database, it also has data management methods available. These methods enable you to add, remove, and update the text documents that are vectorized and indexed within the semantic database.
88

docs/docs/get-started/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
title: Get Started
33
description: Get up and running with SharpVector in minutes. Learn how to install, initialize, and begin storing and searching vectorized text data.
44
---
5-
# Get Started
5+
# :octicons-rocket-24: Get Started
66

77
It's really easy to get started with using `Build5Nines.SharpVector`. Simply follow the below steps.
88

docs/docs/get-started/metadata/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: Metadata
33
---
4-
# Metadata
4+
# :material-database-cog-outline: Metadata
55

66
The `Build5Nines.SharpVector` vector database enables semantic search for `Text` that is stored in the database. Being able to semantically search text is an extremely useful way to lookup more information related to the text. For this purpose, `Metadata` is stored alongside the `Text` within the vector database. This way, when `Text` is found when performing a semantic search, then the matching `Metadata` is also retrieved.
77

docs/docs/get-started/search/index.md

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
---
2+
title: Semantic Search
3+
---
4+
# :material-file-search: Semantic Search
5+
6+
Once text items and their associated metadata have been added to the vector database, the database can be used for semantic search to find matching text items for a given query.
7+
8+
The `BasicMemoryVectorDatabase` and `MemoryVectorDatabase<>` classes both contain `.Search` and `.SearchAsync` methods that can be used to perform semantic search on the database:
9+
10+
=== "Sync"
11+
12+
```csharp
13+
var query = "some text to search";
14+
var results = vdb.Search(query);
15+
```
16+
17+
=== "Async"
18+
19+
```csharp
20+
var query = "some text to search";
21+
var results = await vdb.SearchAsync(query);
22+
```
23+
24+
## Metadata Filters
25+
26+
The `.Search` and `.SearchAsync` methods also include the ability to pre-filter the search results based on a boolean evaluation of the `Metadata` for the text item. This check is run before the vector similarity search is performed, and can help increase search performance on large datasets.
27+
28+
Here are a couple examples of using the `filter` parameter to perform `Metadata` filtering when performing semantic searches:
29+
30+
=== "Sync"
31+
32+
```csharp
33+
var vdb = new BasicMemoryVectorDatabase();
34+
35+
// load text and metadata into database
36+
37+
var query = "some text to search";
38+
var results = vdb.Search(
39+
query,
40+
filter: (metadata) => {
41+
// perform some operation to check metadata
42+
// return true or false
43+
return metadata.Contains("B59");
44+
}
45+
);
46+
```
47+
48+
=== "Async"
49+
50+
```csharp
51+
var vdb = new MemoryVectorDatabase<Person>();
52+
53+
// load text and metadata into database
54+
55+
var query = "some text to search";
56+
var results = vdb.SearchAsync(
57+
query,
58+
filter: async (metadata) => {
59+
// perform some operation to check metadata
60+
// return true or false
61+
return metadata.LastName == "Pietschmann";
62+
}
63+
);
64+
```
65+
66+
!!! info "OpenAI and Ollama Support"
67+
68+
This functionality works the same with both [:simple-openai: OpenAI and :simple-ollama: Ollama supported vector databases](../../embeddings/index.md) too.
69+
70+
## Paging
71+
72+
The `.Search` and `.SearchAsync` methods also include the ability to perform paging on the text items returned from the semantic search. This is performed after the similarity search and the `filter` has been applied to the search results. This is done using the optional `pageCount` and `pageIndex` paramters.
73+
74+
Here are a couple examples of using the `pageCount` and `pageIndex` parameters to perform paging with the semantic search results:
75+
76+
=== "Sync"
77+
78+
```csharp
79+
var vdb = new BasicMemoryVectorDatabase();
80+
81+
// load text and metadata into database
82+
83+
var query = "some text to search";
84+
var results = vdb.Search(
85+
query,
86+
pageIndex: 0, // return first page of results (default: 0)
87+
pageCount: 6 // limit length of this page of results (default: unlimited)
88+
);
89+
```
90+
91+
=== "Async"
92+
93+
```csharp
94+
var vdb = new MemoryVectorDatabase<Person>();
95+
96+
// load text and metadata into database
97+
98+
var query = "some text to search";
99+
var results = vdb.SearchAsync(
100+
query,
101+
pageIndex: 0, // return first page of results (default: 0)
102+
pageCount: 6 // limit length of this page of results (default: unlimited)
103+
);
104+
```
105+
106+
The `pageIndex` and `pageIndex` paramters are optional, and can be used individually or together.

docs/docs/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
title: Discover
33
description: The lightweight, in-memory, semantic search, text vector database for .NET that powers intelligent search and recommendation features.
44
---
5-
# Discover Build5Nines.SharpVector
5+
# :fontawesome-regular-compass: Discover Build5Nines.SharpVector
66

77
**Build5Nines.SharpVector** is the lightweight, in-memory, semantic search, text vector database built for .NET applications. It enables fast and flexible vector-based similarity search for text data — ideal for search engines, recommendation systems, semantic analysis, and AI-enhanced features.
88

docs/docs/license/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ description: Review the MIT license terms for using and contributing to the Shar
44
date: 2025-04-13
55
---
66

7-
# License
7+
# :octicons-file-badge-24: License
88

99
```text
1010
MIT License

docs/docs/persistence/index.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
# Data Persistence
1+
---
2+
title: Data Persistence
3+
---
4+
# :octicons-file-24: Data Persistence
25

36
The `Build5Nines.SharpVector` library provides easy-to-use methods for saving a memory-based vector database to a file or stream and loading it again later. This is particularly useful for caching indexed content between runs, deploying pre-built vector stores, or shipping databases with your application.
47

docs/docs/resources/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ title: Resources
33
description: Dive deeper with curated resources, links, and tools for working with vector databases, semantic search, and SharpVector.
44
---
55

6-
# Resources
6+
# :octicons-link-24: Resources
77

88
## Tutorials
99

docs/docs/samples/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ title: Samples
33
description: Explore real-world code samples to see SharpVector in action. Build search engines, intelligent note apps, and more.
44
---
55

6-
# Samples
6+
# :material-run-fast: Samples
77

88
## Sample Console App
99

docs/docs/text-chunking/index.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
title: Text Chunking
33
description: Learn how to break large documents into smaller chunks to improve vector search relevance and optimize embedding performance.
44
---
5-
# Text Chunking
5+
# :material-script-text: Text Chunking
66

77
**Text chunking** is the process of breaking up large documents into smaller segments ("chunks") before embedding and storing them in a vector database. This allows for more accurate semantic search and improves performance in applications that deal with large bodies of text.
88

@@ -124,7 +124,10 @@ The `TextDataLoader<TKey, TValue>` class can be used to load documents into the
124124
}
125125
```
126126

127-
> 🧠 Tip: Use chunking method and size that best aligns with your content type and retrieval goals.
127+
!!! info "Optimization Tip"
128+
Use chunking method and size that best aligns with your content type and retrieval goals. For larger documents, text chunking will be required to get the best semantic search results returned from the vector database.
129+
130+
Some experimentation on your data set may be required to find the text chunking strategy that works best for your solution.
128131

129132
---
130133

docs/mkdocs.yml

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ markdown_extensions:
6464
- md_in_html
6565
- toc:
6666
permalink: true
67-
toc_depth: 3
67+
toc_depth: 2
6868
- pymdownx.critic
6969
- pymdownx.caret
7070
- pymdownx.keys
@@ -142,18 +142,10 @@ nav:
142142
- Prerequisites: get-started/#prerequisites
143143
- Install Nuget Package: get-started/#install-nuget-package
144144
- Basic Example: get-started/#basic-example
145-
- Metadata:
146-
- get-started/metadata/index.md
147-
- Adding Metadata: get-started/metadata/#adding-metadata
148-
- JSON and String Metadata: get-started/metadata/#json-and-string-metadata
149-
- Custom Metadata Type: get-started/metadata/#custom-metadata-type
150-
151-
- Data Management:
152-
- get-started/data-management/index.md
153-
- Get Text Item Id: get-started/data-management/#get-text-item-id
154-
- Get Item By Id: get-started/data-management/#get
155-
- Update Item: get-started/data-management/#update
156-
- Delete Item: get-started/data-management/#delete
145+
- Metadata: get-started/metadata/index.md
146+
- Semantic search: get-started/search/index.md
147+
- Data Management: get-started/data-management/index.md
148+
157149
- Concepts:
158150
- concepts/index.md
159151
- What is a Vector Database?: concepts/#what-is-a-vector-database

src/SharpVectorTest/VectorDatabaseTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1070,7 +1070,7 @@ public async Task BasicMemoryVectorDatabase_SearchAsync_01()
10701070
[TestMethod]
10711071
public async Task BasicMemoryVectorDatabase_SearchAsync_02()
10721072
{
1073-
var vdb = new BasicMemoryVectorDatabase();
1073+
var vdb = new MemoryVectorDatabase<string>();
10741074

10751075
// // Load Vector Database with some sample text
10761076
vdb.AddText("The 👑 King", "metadata1");

0 commit comments

Comments
 (0)