Union parameter not passed in multi-search queries
還沒有人認領這個 Issue。
評估
研究方向
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.
由索引模型根據 Issue 內容生成。
描述
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.
- 主要語言
- Python
- 星號
- 247
- 分支
- 66
- 平均合併
- 22 小時 47 分鐘
- 30 天內合併 PR
- 8
環境準備
這個專案沒有提供開發容器、Dockerfile 或貢獻指南,環境需要你自己搭建:先看它的 README,通用步驟見我們的新手貢獻指南。
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
typesense/typesense-python 的其他 Issue
-
`MultiSearchResponse` type does not account for union search response shape可能已有人在做 @tharropoulos 於 172 天前認領。 未關閉
難度 2/5 1-3 小時 新手友好度 78/100
typesense/typesense-python#128 ·
-
`documents.Documents.import_()` `batch_size` argument is ignored, type of `import_parameters` is missing `batch_size`可能已有人在做 @tharropoulos 於 245 天前認領。 未關閉
難度 2/5 1-2 天 新手友好度 68/100
typesense/typesense-python#124 ·
-
難度 1/5 1 小時以內 新手友好度 68/100
typesense/typesense-python#100 ·
-
難度 3/5 1-2 天 新手友好度 35/100
typesense/typesense-python#122 · 3 則留言 ·
-
[Bug] - DeprecationWarning on instantiation of Client可能已有人在做 @tharropoulos 於 266 天前認領。 未關閉
難度 3/5 1-2 天 新手友好度 55/100
typesense/typesense-python#114 · 8 則留言 ·
查看 typesense/typesense-python 的全部 Issue
相似的 Issue
-
難度 2/5 1-3 小時 新手友好度 84/100
-
bug
難度 2/5 1-3 小時 新手友好度 77/100
AstrBotDevs/AstrBot#10720 ·
維護者通常 1 天內回覆
-
cause/upstream comp/cli P2 provider/other tool/file type/bug
難度 2/5 1-3 小時 新手友好度 78/100
NousResearch/hermes-agent#143900 ·
維護者通常 1 天內回覆
-
難度 1/5 1-3 小時 新手友好度 85/100
WLAN-Pi/wlanpi-profiler#341 ·
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 77/100
維護者通常 1 天內回覆