on master help sign in
Add non exclusif bang

Allow to perform a search while adding an engine (or a category) without adding it "officially" to the request. '?' is used to add an engine without modifying anything else to the request. For example, you can perform a search in the 'general' category, and if you add '?tw' the result from Twitter will be added to the originals results.

commit96c4d52eef7de13f6fa1d6e0ae651c50c3bba515 authorCqoicebordel <Cqoicebordel@users.noreply.github.com> dateSat 3 Jan 2015, 02:31 (12 years ago) parent7b531c6
2 files changed+6−2
searx/query.py+5−1 searx/search.py+1−1
searx/query.py+5−1
@@ -38,6 +38,7 @@ class Query(object):
3838 self.query_parts = []
3939 self.engines = []
4040 self.languages = []
41+ self.specific = False
4142
4243 # parse query, if tags are set, which
4344 # change the serch engine or search-language
@@ -83,7 +84,7 @@ class Query(object):
8384 break
8485
8586 # this force a engine or category
86− if query_part[0] == '!':
87+ if query_part[0] == '!' or query_part[0] == '?':
8788 prefix = query_part[1:].replace('_', ' ')
8889
8990 # check if prefix is equal with engine shortcut
@@ -110,6 +111,9 @@ class Query(object):
110111 for engine in categories[prefix]
111112 if engine not in self.blocked_engines)
112113
114+ if query_part[0] == '!':
115+ self.specific = True
116+
113117 # append query part to query_part list
114118 self.query_parts.append(query_part)
115119
searx/search.py+1−1
@@ -371,7 +371,7 @@ class Search(object):
371371
372372 # if engines are calculated from query,
373373 # set categories by using that informations
374− if self.engines:
374+ if self.engines and query_obj.specific:
375375 self.categories = list(set(engine['category']
376376 for engine in self.engines))
377377