Fix documentation formatting for get_search_suggestions.

This commit is contained in:
Om Gupta 2023-04-05 14:48:07 +05:30 • committed by sigma67
commit 3d88e75ea5

View file

@ -216,7 +216,9 @@ class SearchMixin:
return search_results return search_results
def get_search_suggestions(self, query: str, detailed_runs=False) -> Union[List, List[Dict]]: def get_search_suggestions(self,
query: str,
detailed_runs=False) -> Union[List[str], List[Dict]]:
""" """
Get Search Suggestions Get Search Suggestions
@ -226,71 +228,61 @@ class SearchMixin:
suggestion along with the complete text (like many search services suggestion along with the complete text (like many search services
usually bold the text typed by the user). usually bold the text typed by the user).
Default: False, returns the list of search suggestions in plain text. Default: False, returns the list of search suggestions in plain text.
:return: List of search suggestion results depending on detailed_runs param. :return: List of search suggestion results depending on ``detailed_runs`` param.
Examples:
1.
Params:
query = 'fade'
detailed_runs = False
Response: Example response when ``query`` is 'fade' and ``detailed_runs`` is set to ``False``::
[
'faded',
'faded alan walker lyrics',
'faded alan walker',
'faded remix',
'faded song',
'faded lyrics',
'faded instrumental'
]
2. [
Params: "faded",
query = 'fade' "faded alan walker lyrics",
detailed_runs = True "faded alan walker",
"faded remix",
"faded song",
"faded lyrics",
"faded instrumental"
]
Response: Example response when ``detailed_runs`` is set to ``True``::
Runs with bold: True show the text typed by user & other runs contain the remaining suggestion.
[ [
{
"text": "faded",
"runs": [
{ {
'text': 'faded', "text": "fade",
'runs': [ "bold": true
{
'text': 'fade',
'bold': True
},
{
'text': 'd'
}
]
}, },
{ {
'text': 'faded alan walker lyrics', "text": "d"
'runs': [ }
{ ]
'text': 'fade', },
'bold': True {
}, "text": "faded alan walker lyrics",
{ "runs": [
'text': 'd alan walker lyrics' {
} "text": "fade",
] "bold": true
}, },
{ {
'text': 'faded alan walker', "text": "d alan walker lyrics"
'runs': [ }
{ ]
'text': 'fade', },
'bold': True {
}, "text": "faded alan walker",
{ "runs": [
'text': 'd alan walker' {
} "text": "fade",
] "bold": true
}, },
... {
] "text": "d alan walker"
}
]
},
...
]
""" """
body = {'input': query} body = {'input': query}