Skip to content

feat(api): Expose search_many() on NamespaceView #244

Description

@shivamm-gupta

Problem

The main client Dynavec provides batch search via db.search_many(queries: list[str], ...) to run several queries concurrently using a thread pool.

However, NamespaceView (returned by db.namespace(...)) exposes search() and search_stream(), but does not expose search_many(). Callers working with a namespace handle currently have to revert back to the root Dynavec instance and manually restate the namespace:

kb = db.namespace("knowledge-base")

# Currently not available:
# kb.search_many(["query 1", "query 2"])

# Workaround requires dropping back to root client:
db.search_many(["query 1", "query 2"], namespace=kb.namespace)

Proposed Solution

  1. Add search_many() to NamespaceView in src/dynavec/namespace.py:
    def search_many(
        self, queries: list[str], *, top_k: int = 10, **kw
    ) -> list[list[SearchResult]]:
        """Run several queries concurrently pinned to this namespace."""
        return self._db.search_many(queries, top_k=top_k, namespace=self._ns, **kw)
  2. Keep it as a thin delegation to the existing client batch search executor without introducing a second thread pool.
  3. Preserve all query options, keyword arguments, result types, and ordering.

Acceptance Criteria

  • Add unit tests in tests/test_namespace.py (or tests/test_client.py):
    • Forwarding multiple queries correctly with namespace isolation.
    • Forwarding keyword arguments (top_k, filters, etc.).
    • Handling empty batch queries=[].
  • Type annotations and docstring matching Dynavec.search_many().

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions