Skip to content

when inserting value in vector data type, parameter needs to be converted to nvarchar max. Otherwise it is getting treated as nText and throwing conversion error. #10

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions Hybrid-Search/hybrid_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@

for id, (content, embedding) in enumerate(zip(sentences, embeddings)):
cursor.execute(f"""
INSERT INTO dbo.documents (id, content, embedding) VALUES (?, ?, CAST(? AS VECTOR(384)));
INSERT INTO dbo.documents (id, content, embedding)
VALUES (?, ?, CAST(CAST(? as NVARCHAR(MAX)) AS VECTOR(384)));
""",
id,
content,
Expand All @@ -59,7 +60,7 @@
results = cursor.execute(f"""
DECLARE @k INT = ?;
DECLARE @q NVARCHAR(1000) = ?;
DECLARE @v VECTOR(384) = CAST(? AS VECTOR(384));
DECLARE @v VECTOR(384) = CAST(CAST(? as NVARCHAR(MAX)) AS VECTOR(384));
WITH keyword_search AS (
SELECT TOP(@k)
id,
Expand Down