Skip to content

Commit

Permalink
py4
Browse files Browse the repository at this point in the history
  • Loading branch information
daveatweaviate committed Sep 13, 2024
1 parent 3b9cfff commit d2bef9c
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion _includes/code/howto/indexes/indexes-v4.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ def print_response_iter(title, response):
dynamic_ef_max=1000, # Maximum threshold for dynamic Ef
),
)

# END EnableHNSW

collection = client.collections.get(collection_name)
Expand Down Expand Up @@ -112,6 +111,31 @@ def print_response_iter(title, response):
== "flat"
), "Wrong index type"

###################
### ENABLE FLAT ###
###################

# Delete data from prior runs
if client.collections.exists(collection_name):
client.collections.delete(collection_name)

# START EnableHNSW
from weaviate.classes.config import Configure, VectorDistances

client.collections.create(
name=collection_name,
vectorizer_config=Configure.Vectorizer.text2vec_cohere(),
# This line enables the index
# vector_index_config=Configure.VectorIndex.hnsw()
# These lines enable and configure the index
vector_index_config=Configure.VectorIndex.flat(
distance_metric=VectorDistances.COSINE,
vector_cache_max_objects=100000,
quantizer=Configure.VectorIndex.Quantizer.bq()
),
)
# END EnableHNSW

################
### CLEAN UP ###
################
Expand Down

0 comments on commit d2bef9c

Please sign in to comment.