Skip to content

Commit

Permalink
fix: Fix migration not working without correct order of index drops
Browse files Browse the repository at this point in the history
Signed-off-by: Diwank Singh Tomer <[email protected]>
  • Loading branch information
creatorrr authored and whiterabbit1983 committed May 3, 2024
1 parent d55b225 commit 68ce7f5
Showing 1 changed file with 45 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
snippet,
embed_instruction,
embedding,
additional_info_id: doc_id,
doc_id,
}
:replace information_snippets {
Expand Down Expand Up @@ -48,7 +48,7 @@
snippet,
embed_instruction,
embedding,
additional_info_id: doc_id,
doc_id,
}
:replace information_snippets {
Expand All @@ -63,48 +63,79 @@
""",
}

information_snippets_hnsw_index = dict(
snippets_hnsw_768_index = dict(
up="""
::hnsw create information_snippets:embedding_space {
fields: [embedding],
filter: !is_null(embedding),
dim: 1024,
dim: 768,
distance: Cosine,
m: 64,
ef_construction: 256,
extend_candidates: false,
extend_candidates: true,
keep_pruned_connections: false,
}
""",
down="""
::hnsw drop information_snippets:embedding_space
""",
)

drop_snippets_hnsw_768_index = {
"up": snippets_hnsw_768_index["down"],
"down": snippets_hnsw_768_index["up"],
}

snippets_hnsw_1024_index = dict(
up="""
::hnsw create information_snippets:embedding_space {
fields: [embedding],
filter: !is_null(embedding),
dim: 768,
dim: 1024,
distance: Cosine,
m: 64,
ef_construction: 256,
extend_candidates: false,
extend_candidates: true,
keep_pruned_connections: false,
}
""",
down="""
::hnsw drop information_snippets:embedding_space
""",
)

drop_index = {
"up": """
::hnsw drop information_snippets:embedding_space
drop_snippets_hnsw_1024_index = {
"up": snippets_hnsw_1024_index["down"],
"down": snippets_hnsw_1024_index["up"],
}


# See: https://docs.cozodb.org/en/latest/vector.html#full-text-search-fts
information_snippets_fts_index = dict(
up="""
::fts create information_snippets:fts {
extractor: concat(title, ' ', snippet),
tokenizer: Simple,
filters: [Lowercase, Stemmer('english'), Stopwords('en')],
}
""",
"down": """
::hnsw drop information_snippets:embedding_space
down="""
::fts drop information_snippets:fts
""",
)

drop_information_snippets_fts_index = {
"up": information_snippets_fts_index["down"],
"down": information_snippets_fts_index["up"],
}


queries_to_run = [
drop_index,
drop_information_snippets_fts_index,
drop_snippets_hnsw_768_index,
change_dimensions,
information_snippets_hnsw_index,
snippets_hnsw_1024_index,
information_snippets_fts_index,
]


Expand Down

0 comments on commit 68ce7f5

Please sign in to comment.