MemoryDB is compatible with Redis OSS, a popular open source data store, enabling you to quickly build applications using the same flexible and friendly Redis OSS data structures, APIs, and commands that they already use today. With MemoryDB, all of your data is stored in memory, which enables you to achieve microsecond read and single-digit millisecond write latency and high throughput. MemoryDB also stores data durably across multiple Availability Zones (AZs) using a Multi-AZ transactional log to enable fast failover, database recovery, and node restarts.
Vector search for MemoryDB extends the functionality of MemoryDB. Vector search can be used in conjunction with existing MemoryDB functionality. Applications that do not use vector search are unaffected by its presence. Vector search is available in all Regions that MemoryDB is available. You can use your existing MemoryDB data or Redis OSS API to build machine learning and generative AI use cases, such as retrieval-augmented generation, anomaly detection, document retrieval, and real-time recommendations.
Indexing of multiple fields in Redis hashes and JSON
Vector similarity search (with HNSW (ANN) or FLAT (KNN))
Vector Range Search (e.g. find all vectors within a radius of a query vector)
# with scores (distances)results = vds.similarity_search_with_score("foo", k=5)for result in results: print(f"Content: {result[0].page_content} --- Score: {result[1]}")
# limit the vector distance that can be returnedresults = vds.similarity_search_with_score("foo", k=5, distance_threshold=0.1)for result in results: print(f"Content: {result[0].page_content} --- Score: {result[1]}")
# with scoresresults = vds.similarity_search_with_relevance_scores("foo", k=5)for result in results: print(f"Content: {result[0].page_content} --- Similarity: {result[1]}")
# you can also add new documents as followsnew_document = ["baz"]new_metadata = [{"user": "sam", "age": 50, "job": "janitor", "credit_score": "high"}]# both the document and metadata must be listsvds.add_texts(new_document, new_metadata)
Here we go over different options for using the vector store as a retriever.There are three different search methods we can use to do retrieval. By default, it will use semantic similarity.
query = "foo"results = vds.similarity_search_with_score(query, k=3, return_metadata=True)for result in results: print("Content:", result[0].page_content, " --- Score: ", result[1])