Perform a vector search
from superduper import Document
def get_sample_item(key, sample_datapoint, datatype=None):
if not isinstance(datatype, DataType):
item = Document({key: sample_datapoint})
else:
item = Document({key: datatype(sample_datapoint)})
return item
if compatible_key:
item = get_sample_item(compatible_key, sample_datapoint, None)
else:
item = get_sample_item(indexing_key, sample_datapoint, datatype=datatype)
Once we have this search target, we can execute a search as follows:
- MongoDB
- SQL
select = query_table_or_collection.like(item, vector_index=vector_index_name, n=10).find()
select = query_table_or_collection.like(item, vector_index=vector_index_name, n=10).limit(10)
results = db.execute(select)