Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

Union parameter not passed in multi-search queries

Đang mở
#95 2 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
55/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
python
Lĩnh vực
api

Hướng nghiên cứu

Start at the MultiSearch.perform entry point shown in the issue and inspect how search_queries becomes the request body. Ensure the Union option is forwarded with the searches, then verify that multi-search requests using Union produce the expected grouped results.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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.

Ngôn ngữ chính
Python
Star
247
Fork
68
Merge trung bình
22 giờ 47 phút
Pull request đã merge (30 ngày)
8

Chuẩn bị môi trường

Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của typesense/typesense-python

Tất cả issue của typesense/typesense-python

Issue tương tự

Thêm issue về Python

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.