OpenSearch is an open-source, enterprise-grade search and observability suite that brings order to unstructured data at scale. OpenSearch supports k-NN (k-Nearest Neighbors) and allows you to store and retrieve high-dimensional vector embeddings efficiently.

Installation

OpenSearch support requires additional dependencies. Install them with:

pip install opensearch>=2.8.0

Usage

import os
from mem0 import Memory

os.environ["OPENAI_API_KEY"] = "sk-xx"

config = {
    "vector_store": {
        "provider": "opensearch",
        "config": {
            "collection_name": "mem0",
            "host": "localhost",
            "port": 9200,
            "embedding_model_dims": 1536
        }
    }
}

m = Memory.from_config(config)
m.add("Likes to play cricket on weekends", user_id="alice", metadata={"category": "hobbies"})

Config

Let’s see the available parameters for the opensearch config:

ParameterDescriptionDefault Value
collection_nameThe name of the index to store the vectorsmem0
embedding_model_dimsDimensions of the embedding model1536
hostThe host where the OpenSearch server is runninglocalhost
portThe port where the OpenSearch server is running9200
api_keyAPI key for authenticationNone
userUsername for basic authenticationNone
passwordPassword for basic authenticationNone
verify_certsWhether to verify SSL certificatesFalse
auto_create_indexWhether to automatically create the indexTrue
use_sslWhether to use SSL for connectionFalse

Features

  • Fast and Efficient Vector Search
  • Can be deployed on-premises, in containers, or on cloud platforms like AWS OpenSearch Service.
  • Multiple Authentication and Security Methods (Basic Authentication, API Keys, LDAP, SAML, and OpenID Connect)
  • Automatic index creation with optimized mappings for vector search
  • Memory Optimization through Disk-Based Vector Search and Quantization
  • Real-Time Analytics and Observability