Working with ManticoreSearch Settings in LangChain

Posted: Jan 29, 2025.

When working with ManticoreSearch vector store in LangChain, you'll need to configure how it connects and behaves using the ManticoreSearchSettings class. This guide covers everything you need to know about configuring ManticoreSearch settings.

What is ManticoreSearchSettings?

ManticoreSearchSettings is a configuration class that lets you customize how LangChain interacts with a ManticoreSearch vector store. It handles connection details, column mappings, and HNSW (Hierarchical Navigable Small World) algorithm parameters for vector similarity search.

Reference

Here are the main configuration options available in ManticoreSearchSettings:

ParameterDescriptionDefault
hostManticoreSearch server hostname'localhost'
portServer port number9308
protoConnection protocol'http'
tableTable name for storing vectors'langchain'
usernameAuthentication usernameNone
passwordAuthentication passwordNone
column_mapDictionary mapping internal to actual column namesDefault mapping*
knn_typeVector search algorithm type'hnsw'
knn_dimsNumber of vector dimensionsNone
hnsw_mHNSW graph max number of connections16
hnsw_ef_constructionHNSW index time quality parameter100
hnsw_similarityHNSW distance metric'L2'

*Default column mapping:

{
    'id': 'id',
    'uuid': 'uuid', 
    'document': 'document',
    'embedding': 'embedding',
    'metadata': 'metadata'
}

How to use ManticoreSearchSettings

Basic Connection Configuration

The simplest way to configure ManticoreSearch is by specifying the connection details:

from langchain_community.vectorstores import ManticoreSearchSettings

settings = ManticoreSearchSettings(
    host="localhost",
    port=9308,
    table="my_vectors"
)

Customizing Column Names

If you want to use different column names in your ManticoreSearch table:

settings = ManticoreSearchSettings(
    table="my_vectors",
    column_map={
        "id": "doc_id",
        "document": "content",
        "embedding": "vector",
        "metadata": "meta"
    }
)

Configuring HNSW Parameters

For fine-tuning vector similarity search performance:

settings = ManticoreSearchSettings(
    table="my_vectors",
    knn_type="hnsw",
    knn_dims=1536,  # Match your embedding dimensions
    hnsw_m=32,  # More connections, better accuracy but slower
    hnsw_ef_construction=200,  # Higher value, better index quality
    hnsw_similarity="cosine"  # Use cosine similarity instead of L2
)

Using Authentication

If your ManticoreSearch server requires authentication:

settings = ManticoreSearchSettings(
    host="manticore.example.com",
    port=9308,
    username="user",
    password="secret",
    proto="https"  # Use HTTPS for secure connections
)

Using with Vector Store

The settings are typically used when creating a ManticoreSearch vector store:

from langchain_community.vectorstores import ManticoreSearch
from langchain_community.embeddings import OpenAIEmbeddings

embeddings = OpenAIEmbeddings()
settings = ManticoreSearchSettings(table="my_vectors")

# Create vector store with settings
vectorstore = ManticoreSearch.from_documents(
    documents,
    embeddings,
    config=settings
)

Remember to adjust these settings based on your specific use case and requirements. The HNSW parameters particularly can have a significant impact on search performance and accuracy.

An alternative to LangSmith

Open-source LangChain monitoring, prompt management, and magic. Get started in 2 minutes.

LangChain Docs

Join 10,000+ subscribers

Every 2 weeks, latest model releases and industry news.

An alternative to LangSmith

Open-source LangChain monitoring, prompt management, and magic. Get started in 2 minutes.

LangChain Docs