Modern search needs go beyond keyword matching — users expect semantic search, fuzzy relevance, and contextual retrieval. Vector databases (Pinecone, Milvus, Weaviate, etc.) store vector embeddings and provide efficient similarity search. Combined with OpenAI (or other embedding models), they let you add semantic search to ASP.NET Core applications with minimal latency and high relevance.
This article explains how to design, implement, and operate a vector-search workflow using ASP.NET Core, OpenAI embeddings, and Pinecone, with practial code examples, architecture guidance and diagrams. Language is simple Indian English and the content suits beginners through experts.
Overview
High-level steps
Generate embeddings for documents/items using an embedding model (OpenAI or local model).
Index embeddings into Pinecone with an ID and metadata.
Store canonical data and metadata in SQL Server (for full retrieval and joins).
For a user query, create an embedding and query Pinecone for nearest neighbors.
Fetch full records from SQL Server using returned IDs and display results in Angular.
Use cases
Product search (e-commerce)
Document / knowledge base search
FAQ and support tickets
Code search and snippets
Semantic filtering and recommendations
High-Level Workflow
User Query (Angular)
↓
ASP.NET Core API → Create embedding (OpenAI)
↓
Query Pinecone (vector DB) —> Pinecone returns nearest vector IDs + scores
↓
Fetch full metadata from SQL Server using IDs
↓
Aggregate, rank and return results to Angular
↓
User sees semantic search results
Flowchart
+--------------------+
| User submits |
| search query |
+---------+----------+
|
v
+---------+----------+
| API receives query |
+---------+----------+
|
v
+---------+----------+
| Create embedding |
| (OpenAI/Model) |
+---------+----------+
|
v
+---------+----------+
| Query Pinecone |
+---------+----------+
|
v
+---------+----------+
| Pinecone returns |
| top N vector IDs |
+---------+----------+
|
v
+---------+----------+
| Fetch rows from DB |
+---------+----------+
|
v
+---------+----------+
| Return results to |
| frontend (Angular) |
+--------------------+
Architecture Diagram (Visio-style)
+----------------------+ +---------------------+ +-------------------+
| Angular Frontend | <---> | ASP.NET Core API | <---> | OpenAI Embedding |
| (Search UI, Filters) | | (Search Controller) | | Service / Model |
+----------------------+ +---------------------+ +-------------------+
|
|
v
+------------------+
| Pinecone |
| Vector DB |
+------------------+
|
v
+------------------+
| SQL Server |
| (metadata, source|
| documents) |
+------------------+
ER Diagram (Minimal mapping)
+----------------------+ +----------------------+
| Documents | 1 --- * | VectorIndex |
+----------------------+ +----------------------+
| DocumentId (PK) | | VectorId (PK) |
| Title | | DocumentId (FK) |
| Content | | Namespace |
| Language | | EmbeddingDimension |
| CreatedOn | | PineconeId |
+----------------------+ | Metadata (JSON) |
| InsertedOn |
+----------------------+
Documentsstores canonical text, titles, URLs, etc.VectorIndextracks which vector belongs to which document and stores Pinecone ID / namespace / metadata for joins.
Sequence Diagram (smaller header)
User -> Angular: enters query
Angular -> API: /api/search?q=...
API -> OpenAI: POST embeddings (query)
OpenAI -> API: embedding vector
API -> Pinecone: query top K vectors
Pinecone -> API: vector IDs + scores
API -> SQL Server: SELECT * FROM Documents WHERE DocumentId IN (...)
SQL Server -> API: document rows
API -> Angular: aggregated search results
Angular -> User: display results
Implementation — Practical Guide
Prerequisites
ASP.NET Core 7/8 project
OpenAI API key (or other embedding service)
Pinecone account + API key + environment (or any vector DB)
SQL Server for metadata
Angular front-end to call API
Note: Use secure secrets management (Azure Key Vault, GitHub Secrets) — never hardcode keys.
Data Model (SQL Server)
Example DDL
CREATE TABLE Documents (
DocumentId UNIQUEIDENTIFIER PRIMARY KEY DEFAULT NEWID(),
Title NVARCHAR(500),
Content NVARCHAR(MAX),
Url NVARCHAR(1000),
Language NVARCHAR(20),
CreatedOn DATETIME2 DEFAULT SYSUTCDATETIME()
);
CREATE TABLE VectorIndex (
VectorId UNIQUEIDENTIFIER PRIMARY KEY DEFAULT NEWID(),
DocumentId UNIQUEIDENTIFIER NOT NULL,
PineconeId NVARCHAR(200) NOT NULL,
Namespace NVARCHAR(200) DEFAULT 'default',
EmbeddingDim INT,
Metadata NVARCHAR(MAX),
InsertedOn DATETIME2 DEFAULT SYSUTCDATETIME(),
FOREIGN KEY (DocumentId) REFERENCES Documents(DocumentId)
);
Embedding & Pinecone Integration (ASP.NET Core)
Below is a simple implementation using HttpClient. In production you may want to use an official SDK if available.
1. Configure services (Startup / Program.cs)
builder.Services.AddHttpClient("OpenAI", c =>
{
c.BaseAddress = new Uri("https://api.openai.com/");
c.DefaultRequestHeaders.Authorization =
new AuthenticationHeaderValue("Bearer", configuration["OPENAI_API_KEY"]);
});
builder.Services.AddHttpClient("Pinecone", c =>
{
c.BaseAddress = new Uri(configuration["PINECONE_BASE_URL"]); // e.g. https://your-project.svc.pinecone.io
c.DefaultRequestHeaders.Add("Api-Key", configuration["PINECONE_API_KEY"]);
});
builder.Services.AddScoped<IEmbeddingService, OpenAiEmbeddingService>();
builder.Services.AddScoped<IVectorService, PineconeVectorService>();

Join the conversation! Your thoughts help the community grow.