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

    Search for items within a namespace prefix.

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

    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.

    Used in Docs

    • Docusaurus integration

    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

    Key-value pairs to filter results.

    limitint
    Default:10

    Maximum number of items to return.

    offsetint
    Default:0

    Number of items to skip before returning results.

    refresh_ttlbool | None
    Default:None

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

    View source on GitHub