Visitar URL original
Union parameter not passed in multi-search queries · Issue #95 · typesense/typesense-python · GitHub
Skip to content

Union parameter not passed in multi-search queries #95

Description

@ragusa87

I tried to use multi-search with "Union" type on typesense==1.1.1.

Snippet:

        for model, collection in model_and_collection:
            query.append(
                {
                    "collection": collection.schema_name,
                    "query_by": collection.query_by_fields,
                    "q": q,
                }
            )
        results = client.multi_search.perform(
            {
                "union": True,
                "searches": query,
            }, {
                "per_page": self.paginate_by,
                "page": page_number,
            }
        )

But I realized that the result doesn't consider the union parameter. I have as many results as collection, and not a "grouped" hits results as expected.

After some investigation, I found out that the parameter "union" is not passed to the query.

    def perform(
        self,
        search_queries: MultiSearchRequestSchema,
        common_params: typing.Union[MultiSearchCommonParameters, None] = None,
    ) -> MultiSearchResponse:
        """
        Perform a multi-search operation.

        This method allows executing multiple search queries in a single API call.
        It processes the search parameters, sends the request to the Typesense API,
        and returns the multi-search response.

        Args:
            search_queries (MultiSearchRequestSchema):
                A dictionary containing the list of search queries to perform.
                The dictionary should have a 'searches' key with a list of search
                    parameter dictionaries.
            common_params (Union[MultiSearchCommonParameters, None], optional):
                Common parameters to apply to all search queries. Defaults to None.

        Returns:
            MultiSearchResponse:
                The response from the multi-search operation, containing
                    the results of all search queries.
        """
        stringified_search_params = [
            stringify_search_params(search_params)
            for search_params in search_queries.get("searches")
        ]
        search_body = {"searches": stringified_search_params}

        response: MultiSearchResponse = self.api_call.post(
            MultiSearch.resource_path,
            body=search_body,
            params=common_params,
            as_json=True,
            entity_type=MultiSearchResponse,
        )
        return response

In the code above, you can see that "union" is not put into search_body.

Adding a line like that fixed it:

search_body["union"] = search_queries.get('union', False)

I will try to submit a MR about it.

Activity

  1. ragusa87 commented on Oct 17, 2025

    @ragusa87
    ContributorAuthor

    Hello @tharropoulos ,

    The fix #96 has been merged, thanks a lot for that.
    Do you have any idea when I could expect a release to integrate it?

    Thanks for your answer!

  2. tharropoulos commented on Oct 17, 2025

    @tharropoulos
    Collaborator

    In the coming weeks, we'll release our v30 GA build for the main server. We'll roll out client updates alongside with it, so keep in an eye out in the coming days!

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions