Skip to content

Commit 5e37a9a

Browse files
committed
enh: optional json return for search
1 parent f3d6c64 commit 5e37a9a

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

‎src/osw/wiki_tools.py‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ class SearchParam(OswBaseModel):
136136
parallel: Optional[bool] = None # is set to true if query is a list longer than 5
137137
debug: Optional[bool] = False
138138
limit: Optional[int] = 1000
139+
return_json: Optional[bool] = False
139140

140141
def __init__(self, **data):
141142
super().__init__(**data)
@@ -208,7 +209,7 @@ def prefix_search_(single_text):
208209

209210
def semantic_search(
210211
site: mwclient.client.Site, query: Union[str, List[str], SearchParam]
211-
) -> List[str]:
212+
) -> Union[List[str], List[dict]]:
212213
"""Semantic query
213214
214215
Parameters
@@ -240,6 +241,9 @@ def semantic_search_(single_query):
240241
single_query, len(result["query"]["results"])
241242
)
242243
)
244+
if query.return_json:
245+
return result
246+
243247
for page in result["query"]["results"].values():
244248
title = page["fulltext"]
245249
exists = page["exists"]

0 commit comments

Comments
 (0)