File tree Expand file tree Collapse file tree 1 file changed +9
-5
lines changed
Expand file tree Collapse file tree 1 file changed +9
-5
lines changed Original file line number Diff line number Diff line change 11from __future__ import annotations
22
3+ import json
34from typing import Annotated
45
56from fastapi import APIRouter , Depends , Query , Request
@@ -33,28 +34,31 @@ async def search_json(
3334 spellcheck_count : int | None = Query (
3435 3 , description = "The number of spellcheck suggestions."
3536 ),
37+ query : str | None = Query (None , description = "JSON query to search for" ),
3638):
3739 """
3840 Performs a search for documents based on the provided query.
3941 """
42+ if query :
43+ final_query = json .loads (query )
44+ else :
45+ final_query = {"q" : q , "page" : page , "limit" : limit }
4046
4147 # Call the underlying search logic
4248 _fields = WorkSearchScheme .default_fetched_fields
4349 if fields :
4450 _fields = fields .split (',' ) # type: ignore
4551
46- query = {"q" : q , "page" : page , "limit" : limit }
47-
48- query .update (
52+ final_query .update (
4953 {key : value for key , value in facets .dict ().items () if value is not None }
5054 )
5155
52- query .update (
56+ final_query .update (
5357 {key : value for key , value in all_fields .dict ().items () if value is not None }
5458 )
5559
5660 response = await work_search_async (
57- query ,
61+ query = final_query ,
5862 sort = sort ,
5963 page = page ,
6064 offset = offset ,
You can’t perform that action at this time.
0 commit comments