-
-
Notifications
You must be signed in to change notification settings - Fork 42
Open
Description
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.
Metadata
Metadata
Assignees
Labels
No labels