File tree Expand file tree Collapse file tree 1 file changed +9
-10
lines changed
Expand file tree Collapse file tree 1 file changed +9
-10
lines changed Original file line number Diff line number Diff line change @@ -276,14 +276,13 @@ print(f"\nDeleted collection '{collection_name}'")
276276``` sql
277277-- Create table with vector column
278278CREATE TABLE articles (
279- id INT PRIMARY KEY ,
280- title TEXT ,
281- content TEXT ,
282- embedding VECTOR(384 )
283- );
284-
285- -- Create vector index for fast similarity search
286- CREATE INDEX idx_vector ON articles USING VECTOR (embedding);
279+ id INT PRIMARY KEY ,
280+ title TEXT ,
281+ content TEXT ,
282+ embedding VECTOR(384 ),
283+ FULLTEXT INDEX idx_fts(content) WITH PARSER ik,
284+ VECTOR INDEX idx_vec (embedding) WITH(DISTANCE= l2, TYPE= hnsw, LIB= vsag)
285+ ) ORGANIZATION = HEAP;
287286
288287-- Insert documents with embeddings
289288-- Note: Embeddings should be pre-computed using your embedding model
@@ -298,11 +297,11 @@ VALUES
298297SELECT
299298 title,
300299 content,
301- embedding < - > ' [query_embedding]' AS vector_distance,
300+ l2_distance( embedding, ' [query_embedding]' ) AS vector_distance,
302301 MATCH(content) AGAINST(' your keywords' IN NATURAL LANGUAGE MODE) AS text_score
303302FROM articles
304303WHERE MATCH(content) AGAINST(' your keywords' IN NATURAL LANGUAGE MODE)
305- ORDER BY vector_distance ASC , text_score DESC
304+ ORDER BY vector_distance APPROXIMATE
306305LIMIT 10 ;
307306```
308307
You can’t perform that action at this time.
0 commit comments