on master help sign in
[enh] make search type of mediawiki configurable
2db8073Noémi Ványi
searx/engines/mediawiki.py+4−2
@@ -21,6 +21,7 @@ categories = ['general']
21language_support = True
21language_support = True
22paging = True
22paging = True
23number_of_results = 1
23number_of_results = 1
24+search_type = 'nearmatch' # possible values: title, text, nearmatch
24
25
25# search-url
26# search-url
26base_url = 'https://{language}.wikipedia.org/'
27base_url = 'https://{language}.wikipedia.org/'
@@ -30,7 +31,7 @@ search_postfix = 'w/api.php?action=query'\
30 '&format=json'\
31 '&format=json'\
31 '&sroffset={offset}'\
32 '&sroffset={offset}'\
32 '&srlimit={limit}'\
33 '&srlimit={limit}'\
33− '&srwhat=nearmatch' # search for a near match in the title
34+ '&srwhat={searchtype}' # search for a near match in the title
34
35
35
36
36# do search-request
37# do search-request
@@ -39,7 +40,8 @@ def request(query, params):
39
40
40 string_args = dict(query=urlencode({'srsearch': query}),
41 string_args = dict(query=urlencode({'srsearch': query}),
41 offset=offset,
42 offset=offset,
42− limit=number_of_results)
43+ limit=number_of_results,
44+ searchtype=search_type)
43
45
44 format_strings = list(Formatter().parse(base_url))
46 format_strings = list(Formatter().parse(base_url))
45
47