mirror of
https://github.com/marcominerva/SqlDatabaseVectorSearch.git
synced 2026-06-20 12:23:10 +00:00
45de38d87a
- Updated `Scripts.sql` to add a new `[Index]` column to `[dbo].[DocumentChunks]` for order tracking. - Modified `DocumentChunk.cs` to include a new `Index` property, and introduced a new immutable record class for document chunks. - Introduced new API endpoints in `Program.cs` for document and chunk retrieval, including embedding details, with OpenAPI documentation enhancements. - Updated an API endpoint description in `Program.cs` to clarify document embedding handling. - Updated `VectorSearchService.cs` to reflect schema changes in service logic, adding methods for fetching document chunks and specific embeddings.
32 lines
868 B
Transact-SQL
32 lines
868 B
Transact-SQL
CREATE TABLE [dbo].[DocumentChunks](
|
|
[Id] [uniqueidentifier] NOT NULL,
|
|
[DocumentId] [uniqueidentifier] NOT NULL,
|
|
[Index] INT NOT NULL,
|
|
[Content] [nvarchar](max) NOT NULL,
|
|
[Embedding] [varbinary](8000) NOT NULL,
|
|
CONSTRAINT [PK_DocumentChunks] PRIMARY KEY CLUSTERED
|
|
(
|
|
[Id] ASC
|
|
))
|
|
GO
|
|
|
|
CREATE TABLE [dbo].[Documents](
|
|
[Id] [uniqueidentifier] NOT NULL,
|
|
[Name] [nvarchar](255) NOT NULL,
|
|
[CreationDate] [datetimeoffset](7) NOT NULL,
|
|
CONSTRAINT [PK_Documents] PRIMARY KEY CLUSTERED
|
|
(
|
|
[Id] ASC
|
|
))
|
|
GO
|
|
|
|
ALTER TABLE [dbo].[DocumentChunks] ADD CONSTRAINT [DF_DocumentChunks_Id] DEFAULT (newid()) FOR [Id]
|
|
GO
|
|
|
|
ALTER TABLE [dbo].[Documents] ADD CONSTRAINT [DF_Documents_Id] DEFAULT (newid()) FOR [Id]
|
|
GO
|
|
|
|
ALTER TABLE [dbo].[DocumentChunks] WITH CHECK ADD CONSTRAINT [FK_DocumentChunks_Documents] FOREIGN KEY([DocumentId])
|
|
REFERENCES [dbo].[Documents] ([Id])
|
|
GO
|