You can filter query results based on metadata fields. For example, to filter items where the age field is greater than 18, you can use the following filter:
[{"age": {"$gt": 18}}]
This filter will return items where the age field is greater than 18. You can also use other comparison operators such as $lt, $gte, $lte, $eq, and $neq.For more details on metadata filters, see the Metadata Filtering guide.
This feature is only available in Python and is experimental as of v0.9.0.
If you provided an embedding_model during index creation, you can automatically generate embeddings for queries by providing query_contents to the query() call:
Python
# ... index creation and embedding model setupembedding_model = "all-MiniLM-L6-v2"index = client.create_index("my_index", index_key, index_config, embedding_model)# ... Add items to the encrypted index ...# Example queryquery_contents = "What is the capital of France?"top_k = 10# Perform queryresults = index.query(query_contents=query_contents, top_k=top_k)
In certain applications, such as RAG, it may be desirable to retrieve matching items after a query. This is possible via get(), which retrieves and decrypts item added via upsert(). For more details, see the Get Items guide.
For the embedded lib version of CyborgDB, queries will initially default to ‘untrained’ queries, which use an exhaustive search algorithm. This is fine for small datasets, but once you have more than 50,000 vectors in your index, you should train the index. Without doing so, queries will run slower. For more details, see Training an Encrypted Index.