LangChain Reference home pageLangChain ReferenceLangChain Reference
  • GitHub
  • Main Docs
Deep Agents
LangChain
LangGraph
Integrations
LangSmith
  • Overview
  • LangGraph Checkpoint
    LangGraph Store
    Checkpoint Postgres
    Store Postgres
    Checkpoint SQLite
    LangGraph Prebuilt
    LangGraph CLI
    LangGraph SDK
    LangGraph Supervisor
    LangGraph Swarm
    ⌘I

    LangChain Assistant

    Ask a question to get started

    Enter to send•Shift+Enter new line

    Menu

    LangGraph Checkpoint
    LangGraph Store
    Checkpoint Postgres
    Store Postgres
    Checkpoint SQLite
    LangGraph Prebuilt
    LangGraph CLI
    LangGraph SDK
    LangGraph Supervisor
    LangGraph Swarm
    Language
    Theme
    Pythonlanggraph.storebaseBaseStoresearch
    Method●Since v1.0

    search

    Copy
    search(
      self,
      namespace_prefix: tuple[str, ...],
      ,
      *,
      query: str
    View source on GitHub
    |
    None
    =
    None
    ,
    filter
    :
    dict
    [
    str
    ,
    Any
    ]
    |
    None
    =
    None
    ,
    limit
    :
    int
    =
    10
    ,
    offset
    :
    int
    =
    0
    ,
    refresh_ttl
    :
    bool
    |
    None
    =
    None
    )
    ->
    list
    [
    SearchItem
    ]

    Parameters

    NameTypeDescription
    namespace_prefix*tuple[str, ...]

    Hierarchical path prefix to search within.

    querystr | None
    Default:None

    Optional query for natural language search.

    filterdict[str, Any] | None
    Default:None
    limitint
    Default:10
    offsetint
    Default:0
    refresh_ttlbool | None
    Default:None

    Search for items within a namespace prefix.

    Basic filtering:

    # Search for documents with specific metadata
    results = store.search(
        ("docs",),
        filter={"type": "article", "status": "published"}
    )

    Natural language search (requires vector store implementation):

    # Initialize store with embedding configuration
    store = YourStore( # e.g., InMemoryStore, AsyncPostgresStore
        index={
            "dims": 1536,  # embedding dimensions
            "embed": your_embedding_function,  # function to create embeddings
            "fields": ["text"]  # fields to embed. Defaults to ["$"]
        }
    )
    
    # Search for semantically similar documents
    
    results = store.search(
        ("docs",),
        query="machine learning applications in healthcare",
        filter={"type": "research_paper"},
        limit=5
    )
    Note

    Natural language search support depends on your store implementation and requires proper embedding configuration.

    Key-value pairs to filter results.

    Maximum number of items to return.

    Number of items to skip before returning results.

    Whether to refresh TTLs for the returned items. If no TTL is specified, this argument is ignored.