prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  Search: search doesn't appear to use the organization
  Example: the MapAction org has two public datasets, but searching "mapaction" or MapAction returns 0 results.  
  
  Other org searches will return results, but this is probably because the name of the org is mentioned in other metadata. 
  
  To do: 
  1. confirm that search queries from the homepage or main search bar are not using organizations
  2. if that is the source of the problem, add org to the search queries
  
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `ckanext-hdx_search/ckanext/hdx_search/plugin.py`
  Content:
  ```
  1 import logging
  2 import ckan.plugins as plugins
  3 import ckan.plugins.toolkit as tk
  4 import ckan.lib.plugins as lib_plugins
  5 
  6 
  7 class HDXSearchPlugin(plugins.SingletonPlugin):
  8     plugins.implements(plugins.IConfigurer, inherit=False)
  9     plugins.implements(plugins.IRoutes, inherit=True)
  10     plugins.implements(plugins.ITemplateHelpers, inherit=False)
  11     plugins.implements(plugins.IPackageController, inherit=True)
  12 
  13     def update_config(self, config):
  14         tk.add_template_directory(config, 'templates')
  15 
  16     def get_helpers(self):
  17         return {}
  18 
  19     def before_map(self, map):
  20         map.connect('search', '/search',
  21                     controller='ckanext.hdx_search.controllers.search_controller:HDXSearchController', action='search')
  22         map.connect('simple_search',
  23             '/dataset', controller='ckanext.hdx_search.controllers.simple_search_controller:HDXSimpleSearchController', action='package_search')
  24         return map
  25 
  26     def after_map(self, map):
  27         map.connect('search', '/search',
  28                     controller='ckanext.hdx_search.controllers.search_controller:HDXSearchController', action='search')
  29         map.connect('simple_search',
  30             '/dataset', controller='ckanext.hdx_search.controllers.simple_search_controller:HDXSimpleSearchController', action='package_search')
  31         return map
  32 
  33     def before_search(self, search_params):
  34         if 'facet.field' in search_params and 'vocab_Topics' not in search_params['facet.field']:
  35             search_params['facet.field'].append('vocab_Topics')
  36 
  37         # If indicator flag is set, search only that type
  38         if 'ext_indicator' in search_params['extras']:
  39             if int(search_params['extras']['ext_indicator']) == 1:
  40                 search_params['fq'] = search_params['fq'] + ' +extras_indicator:1'
  41             elif int(search_params['extras']['ext_indicator']) == 0:
  42                 search_params['fq'] = search_params[
  43                     'fq'] + ' -extras_indicator:1'
  44         return search_params
  45 
  46     def after_search(self, search_results, search_params):
  47         return search_results
  48 
  49     def before_view(self, pkg_dict):
  50         return pkg_dict
  51
  ```
  --- END FILES ---
  
  Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.
  
  Here is an example:
  
  ```diff
  diff --git a/examples/server_async.py b/examples/server_async.py
  --- a/examples/server_async.py
  +++ b/examples/server_async.py
  @@ -313,4 +313,4 @@
   
   
   if __name__ == "__main__":
  -    asyncio.run(run_async_server("."), debug=True)
  +    asyncio.run(run_async_server(), debug=True)
  diff --git a/examples/server_sync.py b/examples/server_sync.py
  --- a/examples/server_sync.py
  +++ b/examples/server_sync.py
  @@ -313,5 +313,5 @@
   
   
   if __name__ == "__main__":
  -    server = run_sync_server(".")
  +    server = run_sync_server()
       server.shutdown()
  
  ```
  
golden_diff: diff --git a/ckanext-hdx_search/ckanext/hdx_search/plugin.py b/ckanext-hdx_search/ckanext/hdx_search/plugin.py
  --- a/ckanext-hdx_search/ckanext/hdx_search/plugin.py
  +++ b/ckanext-hdx_search/ckanext/hdx_search/plugin.py
  @@ -1,8 +1,13 @@
  -import logging
  +import logging, re
   import ckan.plugins as plugins
   import ckan.plugins.toolkit as tk
   import ckan.lib.plugins as lib_plugins
   
  +def convert_country(q):
  +    for c in tk.get_action('group_list')({'user':'127.0.0.1'},{'all_fields': True}):
  +        if re.findall(c['display_name'].lower(),q.lower()):
  +            q += ' '+c['name']
  +    return q
   
   class HDXSearchPlugin(plugins.SingletonPlugin):
       plugins.implements(plugins.IConfigurer, inherit=False)
  @@ -31,6 +36,7 @@
           return map
   
       def before_search(self, search_params):
  +        search_params['q'] = convert_country(search_params['q'])
           if 'facet.field' in search_params and 'vocab_Topics' not in search_params['facet.field']:
               search_params['facet.field'].append('vocab_Topics')
  
verification_info: {"golden_diff": "diff --git a/ckanext-hdx_search/ckanext/hdx_search/plugin.py b/ckanext-hdx_search/ckanext/hdx_search/plugin.py\n--- a/ckanext-hdx_search/ckanext/hdx_search/plugin.py\n+++ b/ckanext-hdx_search/ckanext/hdx_search/plugin.py\n@@ -1,8 +1,13 @@\n-import logging\n+import logging, re\n import ckan.plugins as plugins\n import ckan.plugins.toolkit as tk\n import ckan.lib.plugins as lib_plugins\n \n+def convert_country(q):\n+    for c in tk.get_action('group_list')({'user':'127.0.0.1'},{'all_fields': True}):\n+        if re.findall(c['display_name'].lower(),q.lower()):\n+            q += ' '+c['name']\n+    return q\n \n class HDXSearchPlugin(plugins.SingletonPlugin):\n     plugins.implements(plugins.IConfigurer, inherit=False)\n@@ -31,6 +36,7 @@\n         return map\n \n     def before_search(self, search_params):\n+        search_params['q'] = convert_country(search_params['q'])\n         if 'facet.field' in search_params and 'vocab_Topics' not in search_params['facet.field']:\n             search_params['facet.field'].append('vocab_Topics')\n", "issue": "Search: search doesn't appear to use the organization\nExample: the MapAction org has two public datasets, but searching \"mapaction\" or MapAction returns 0 results.  \n\nOther org searches will return results, but this is probably because the name of the org is mentioned in other metadata. \n\nTo do: \n1. confirm that search queries from the homepage or main search bar are not using organizations\n2. if that is the source of the problem, add org to the search queries\n\n", "before_files": [{"content": "import logging\nimport ckan.plugins as plugins\nimport ckan.plugins.toolkit as tk\nimport ckan.lib.plugins as lib_plugins\n\n\nclass HDXSearchPlugin(plugins.SingletonPlugin):\n    plugins.implements(plugins.IConfigurer, inherit=False)\n    plugins.implements(plugins.IRoutes, inherit=True)\n    plugins.implements(plugins.ITemplateHelpers, inherit=False)\n    plugins.implements(plugins.IPackageController, inherit=True)\n\n    def update_config(self, config):\n        tk.add_template_directory(config, 'templates')\n\n    def get_helpers(self):\n        return {}\n\n    def before_map(self, map):\n        map.connect('search', '/search',\n                    controller='ckanext.hdx_search.controllers.search_controller:HDXSearchController', action='search')\n        map.connect('simple_search',\n            '/dataset', controller='ckanext.hdx_search.controllers.simple_search_controller:HDXSimpleSearchController', action='package_search')\n        return map\n\n    def after_map(self, map):\n        map.connect('search', '/search',\n                    controller='ckanext.hdx_search.controllers.search_controller:HDXSearchController', action='search')\n        map.connect('simple_search',\n            '/dataset', controller='ckanext.hdx_search.controllers.simple_search_controller:HDXSimpleSearchController', action='package_search')\n        return map\n\n    def before_search(self, search_params):\n        if 'facet.field' in search_params and 'vocab_Topics' not in search_params['facet.field']:\n            search_params['facet.field'].append('vocab_Topics')\n\n        # If indicator flag is set, search only that type\n        if 'ext_indicator' in search_params['extras']:\n            if int(search_params['extras']['ext_indicator']) == 1:\n                search_params['fq'] = search_params['fq'] + ' +extras_indicator:1'\n            elif int(search_params['extras']['ext_indicator']) == 0:\n                search_params['fq'] = search_params[\n                    'fq'] + ' -extras_indicator:1'\n        return search_params\n\n    def after_search(self, search_results, search_params):\n        return search_results\n\n    def before_view(self, pkg_dict):\n        return pkg_dict\n", "path": "ckanext-hdx_search/ckanext/hdx_search/plugin.py"}], "after_files": [{"content": "import logging, re\nimport ckan.plugins as plugins\nimport ckan.plugins.toolkit as tk\nimport ckan.lib.plugins as lib_plugins\n\ndef convert_country(q):\n    for c in tk.get_action('group_list')({'user':'127.0.0.1'},{'all_fields': True}):\n        if re.findall(c['display_name'].lower(),q.lower()):\n            q += ' '+c['name']\n    return q\n\nclass HDXSearchPlugin(plugins.SingletonPlugin):\n    plugins.implements(plugins.IConfigurer, inherit=False)\n    plugins.implements(plugins.IRoutes, inherit=True)\n    plugins.implements(plugins.ITemplateHelpers, inherit=False)\n    plugins.implements(plugins.IPackageController, inherit=True)\n\n    def update_config(self, config):\n        tk.add_template_directory(config, 'templates')\n\n    def get_helpers(self):\n        return {}\n\n    def before_map(self, map):\n        map.connect('search', '/search',\n                    controller='ckanext.hdx_search.controllers.search_controller:HDXSearchController', action='search')\n        map.connect('simple_search',\n            '/dataset', controller='ckanext.hdx_search.controllers.simple_search_controller:HDXSimpleSearchController', action='package_search')\n        return map\n\n    def after_map(self, map):\n        map.connect('search', '/search',\n                    controller='ckanext.hdx_search.controllers.search_controller:HDXSearchController', action='search')\n        map.connect('simple_search',\n            '/dataset', controller='ckanext.hdx_search.controllers.simple_search_controller:HDXSimpleSearchController', action='package_search')\n        return map\n\n    def before_search(self, search_params):\n        search_params['q'] = convert_country(search_params['q'])\n        if 'facet.field' in search_params and 'vocab_Topics' not in search_params['facet.field']:\n            search_params['facet.field'].append('vocab_Topics')\n\n        # If indicator flag is set, search only that type\n        if 'ext_indicator' in search_params['extras']:\n            if int(search_params['extras']['ext_indicator']) == 1:\n                search_params['fq'] = search_params['fq'] + ' +extras_indicator:1'\n            elif int(search_params['extras']['ext_indicator']) == 0:\n                search_params['fq'] = search_params[\n                    'fq'] + ' -extras_indicator:1'\n        return search_params\n\n    def after_search(self, search_results, search_params):\n        return search_results\n\n    def before_view(self, pkg_dict):\n        return pkg_dict\n", "path": "ckanext-hdx_search/ckanext/hdx_search/plugin.py"}]}