prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  Discover page: search box does NOT obey SOLR syntax
  The helpful text that suggests that SOLR syntax works in the search box has been wrong for over a year. It now tokenizes terms and is not compatible with SOLR syntax. 
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `hs_core/discovery_form.py`
  Content:
  ```
  1 from haystack.forms import FacetedSearchForm
  2 from haystack.query import SQ, SearchQuerySet
  3 from crispy_forms.layout import *
  4 from crispy_forms.bootstrap import *
  5 from django import forms
  6 
  7 class DiscoveryForm(FacetedSearchForm):
  8     NElat = forms.CharField(widget = forms.HiddenInput(), required=False)
  9     NElng = forms.CharField(widget = forms.HiddenInput(), required=False)
  10     SWlat = forms.CharField(widget = forms.HiddenInput(), required=False)
  11     SWlng = forms.CharField(widget = forms.HiddenInput(), required=False)
  12     start_date = forms.DateField(label='From Date', required=False)
  13     end_date = forms.DateField(label='To Date', required=False)
  14 
  15     def search(self):
  16         if not self.cleaned_data.get('q'):
  17             sqs = self.searchqueryset.filter(discoverable=True).filter(is_replaced_by=False)
  18         else:
  19             # This corrects for an failed match of complete words, as documented in issue #2308.
  20             # The text__startswith=cdata matches stemmed words in documents with an unstemmed cdata.
  21             # The text=cdata matches stemmed words after stemming cdata as well.
  22             # The stem of "Industrial", according to the aggressive default stemmer, is "industri".
  23             # Thus "Industrial" does not match "Industrial" in the document according to
  24             # startswith, but does match according to text=cdata.
  25             cdata = self.cleaned_data.get('q')
  26             sqs = self.searchqueryset.filter(SQ(text__startswith=cdata)|SQ(text=cdata))\
  27                 .filter(discoverable=True)\
  28                 .filter(is_replaced_by=False)
  29 
  30         geo_sq = SQ()
  31         if self.cleaned_data['NElng'] and self.cleaned_data['SWlng']:
  32             if float(self.cleaned_data['NElng']) > float(self.cleaned_data['SWlng']):
  33                 geo_sq.add(SQ(coverage_east__lte=float(self.cleaned_data['NElng'])), SQ.AND)
  34                 geo_sq.add(SQ(coverage_east__gte=float(self.cleaned_data['SWlng'])), SQ.AND)
  35             else:
  36                 geo_sq.add(SQ(coverage_east__gte=float(self.cleaned_data['SWlng'])), SQ.AND)
  37                 geo_sq.add(SQ(coverage_east__lte=float(180)), SQ.OR)
  38                 geo_sq.add(SQ(coverage_east__lte=float(self.cleaned_data['NElng'])), SQ.AND)
  39                 geo_sq.add(SQ(coverage_east__gte=float(-180)), SQ.AND)
  40 
  41         if self.cleaned_data['NElat'] and self.cleaned_data['SWlat']:
  42             geo_sq.add(SQ(coverage_north__lte=float(self.cleaned_data['NElat'])), SQ.AND)
  43             geo_sq.add(SQ(coverage_north__gte=float(self.cleaned_data['SWlat'])), SQ.AND)
  44 
  45         if geo_sq:
  46             sqs = sqs.filter(geo_sq)
  47 
  48 
  49         # Check to see if a start_date was chosen.
  50         if self.cleaned_data['start_date']:
  51             sqs = sqs.filter(coverage_start_date__gte=self.cleaned_data['start_date'])
  52 
  53         # Check to see if an end_date was chosen.
  54         if self.cleaned_data['end_date']:
  55             sqs = sqs.filter(coverage_end_date__lte=self.cleaned_data['end_date'])
  56 
  57         author_sq = SQ()
  58         subjects_sq = SQ()
  59         resource_sq = SQ()
  60         public_sq = SQ()
  61         owner_sq = SQ()
  62         discoverable_sq = SQ()
  63         published_sq = SQ()
  64         variable_sq = SQ()
  65         sample_medium_sq = SQ()
  66         units_name_sq = SQ()
  67         # We need to process each facet to ensure that the field name and the
  68         # value are quoted correctly and separately:
  69 
  70         for facet in self.selected_facets:
  71             if ":" not in facet:
  72                 continue
  73 
  74             field, value = facet.split(":", 1)
  75 
  76             if value:
  77                 if "creators" in field:
  78                     author_sq.add(SQ(creators=sqs.query.clean(value)), SQ.OR)
  79 
  80                 elif "subjects" in field:
  81                     subjects_sq.add(SQ(subjects=sqs.query.clean(value)), SQ.OR)
  82 
  83                 elif "resource_type" in field:
  84                     resource_sq.add(SQ(resource_type=sqs.query.clean(value)), SQ.OR)
  85 
  86                 elif "public" in field:
  87                     public_sq.add(SQ(public=sqs.query.clean(value)), SQ.OR)
  88 
  89                 elif "owners_names" in field:
  90                     owner_sq.add(SQ(owners_names=sqs.query.clean(value)), SQ.OR)
  91 
  92                 elif "discoverable" in field:
  93                     discoverable_sq.add(SQ(discoverable=sqs.query.clean(value)), SQ.OR)
  94 
  95                 elif "published" in field:
  96                     published_sq.add(SQ(published=sqs.query.clean(value)), SQ.OR)
  97 
  98                 elif 'variable_names' in field:
  99                     variable_sq.add(SQ(variable_names=sqs.query.clean(value)), SQ.OR)
  100 
  101                 elif 'sample_mediums' in field:
  102                     sample_medium_sq.add(SQ(sample_mediums=sqs.query.clean(value)), SQ.OR)
  103 
  104                 elif 'units_names' in field:
  105                     units_name_sq.add(SQ(units_names=sqs.query.clean(value)), SQ.OR)
  106 
  107                 else:
  108                     continue
  109 
  110         if author_sq:
  111             sqs = sqs.filter(author_sq)
  112         if subjects_sq:
  113             sqs = sqs.filter(subjects_sq)
  114         if resource_sq:
  115             sqs = sqs.filter(resource_sq)
  116         if public_sq:
  117             sqs = sqs.filter(public_sq)
  118         if owner_sq:
  119             sqs = sqs.filter(owner_sq)
  120         if discoverable_sq:
  121             sqs = sqs.filter(discoverable_sq)
  122         if published_sq:
  123             sqs = sqs.filter(published_sq)
  124         if variable_sq:
  125             sqs = sqs.filter(variable_sq)
  126         if sample_medium_sq:
  127             sqs = sqs.filter(sample_medium_sq)
  128         if units_name_sq:
  129             sqs = sqs.filter(units_name_sq)
  130 
  131         return sqs
  132
  ```
  --- 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/hs_core/discovery_form.py b/hs_core/discovery_form.py
  --- a/hs_core/discovery_form.py
  +++ b/hs_core/discovery_form.py
  @@ -1,7 +1,5 @@
   from haystack.forms import FacetedSearchForm
  -from haystack.query import SQ, SearchQuerySet
  -from crispy_forms.layout import *
  -from crispy_forms.bootstrap import *
  +from haystack.query import SQ
   from django import forms
   
   class DiscoveryForm(FacetedSearchForm):
  
verification_info: {"golden_diff": "diff --git a/hs_core/discovery_form.py b/hs_core/discovery_form.py\n--- a/hs_core/discovery_form.py\n+++ b/hs_core/discovery_form.py\n@@ -1,7 +1,5 @@\n from haystack.forms import FacetedSearchForm\n-from haystack.query import SQ, SearchQuerySet\n-from crispy_forms.layout import *\n-from crispy_forms.bootstrap import *\n+from haystack.query import SQ\n from django import forms\n \n class DiscoveryForm(FacetedSearchForm):\n", "issue": "Discover page: search box does NOT obey SOLR syntax\nThe helpful text that suggests that SOLR syntax works in the search box has been wrong for over a year. It now tokenizes terms and is not compatible with SOLR syntax. \n", "before_files": [{"content": "from haystack.forms import FacetedSearchForm\nfrom haystack.query import SQ, SearchQuerySet\nfrom crispy_forms.layout import *\nfrom crispy_forms.bootstrap import *\nfrom django import forms\n\nclass DiscoveryForm(FacetedSearchForm):\n    NElat = forms.CharField(widget = forms.HiddenInput(), required=False)\n    NElng = forms.CharField(widget = forms.HiddenInput(), required=False)\n    SWlat = forms.CharField(widget = forms.HiddenInput(), required=False)\n    SWlng = forms.CharField(widget = forms.HiddenInput(), required=False)\n    start_date = forms.DateField(label='From Date', required=False)\n    end_date = forms.DateField(label='To Date', required=False)\n\n    def search(self):\n        if not self.cleaned_data.get('q'):\n            sqs = self.searchqueryset.filter(discoverable=True).filter(is_replaced_by=False)\n        else:\n            # This corrects for an failed match of complete words, as documented in issue #2308.\n            # The text__startswith=cdata matches stemmed words in documents with an unstemmed cdata.\n            # The text=cdata matches stemmed words after stemming cdata as well.\n            # The stem of \"Industrial\", according to the aggressive default stemmer, is \"industri\".\n            # Thus \"Industrial\" does not match \"Industrial\" in the document according to\n            # startswith, but does match according to text=cdata.\n            cdata = self.cleaned_data.get('q')\n            sqs = self.searchqueryset.filter(SQ(text__startswith=cdata)|SQ(text=cdata))\\\n                .filter(discoverable=True)\\\n                .filter(is_replaced_by=False)\n\n        geo_sq = SQ()\n        if self.cleaned_data['NElng'] and self.cleaned_data['SWlng']:\n            if float(self.cleaned_data['NElng']) > float(self.cleaned_data['SWlng']):\n                geo_sq.add(SQ(coverage_east__lte=float(self.cleaned_data['NElng'])), SQ.AND)\n                geo_sq.add(SQ(coverage_east__gte=float(self.cleaned_data['SWlng'])), SQ.AND)\n            else:\n                geo_sq.add(SQ(coverage_east__gte=float(self.cleaned_data['SWlng'])), SQ.AND)\n                geo_sq.add(SQ(coverage_east__lte=float(180)), SQ.OR)\n                geo_sq.add(SQ(coverage_east__lte=float(self.cleaned_data['NElng'])), SQ.AND)\n                geo_sq.add(SQ(coverage_east__gte=float(-180)), SQ.AND)\n\n        if self.cleaned_data['NElat'] and self.cleaned_data['SWlat']:\n            geo_sq.add(SQ(coverage_north__lte=float(self.cleaned_data['NElat'])), SQ.AND)\n            geo_sq.add(SQ(coverage_north__gte=float(self.cleaned_data['SWlat'])), SQ.AND)\n\n        if geo_sq:\n            sqs = sqs.filter(geo_sq)\n\n\n        # Check to see if a start_date was chosen.\n        if self.cleaned_data['start_date']:\n            sqs = sqs.filter(coverage_start_date__gte=self.cleaned_data['start_date'])\n\n        # Check to see if an end_date was chosen.\n        if self.cleaned_data['end_date']:\n            sqs = sqs.filter(coverage_end_date__lte=self.cleaned_data['end_date'])\n\n        author_sq = SQ()\n        subjects_sq = SQ()\n        resource_sq = SQ()\n        public_sq = SQ()\n        owner_sq = SQ()\n        discoverable_sq = SQ()\n        published_sq = SQ()\n        variable_sq = SQ()\n        sample_medium_sq = SQ()\n        units_name_sq = SQ()\n        # We need to process each facet to ensure that the field name and the\n        # value are quoted correctly and separately:\n\n        for facet in self.selected_facets:\n            if \":\" not in facet:\n                continue\n\n            field, value = facet.split(\":\", 1)\n\n            if value:\n                if \"creators\" in field:\n                    author_sq.add(SQ(creators=sqs.query.clean(value)), SQ.OR)\n\n                elif \"subjects\" in field:\n                    subjects_sq.add(SQ(subjects=sqs.query.clean(value)), SQ.OR)\n\n                elif \"resource_type\" in field:\n                    resource_sq.add(SQ(resource_type=sqs.query.clean(value)), SQ.OR)\n\n                elif \"public\" in field:\n                    public_sq.add(SQ(public=sqs.query.clean(value)), SQ.OR)\n\n                elif \"owners_names\" in field:\n                    owner_sq.add(SQ(owners_names=sqs.query.clean(value)), SQ.OR)\n\n                elif \"discoverable\" in field:\n                    discoverable_sq.add(SQ(discoverable=sqs.query.clean(value)), SQ.OR)\n\n                elif \"published\" in field:\n                    published_sq.add(SQ(published=sqs.query.clean(value)), SQ.OR)\n\n                elif 'variable_names' in field:\n                    variable_sq.add(SQ(variable_names=sqs.query.clean(value)), SQ.OR)\n\n                elif 'sample_mediums' in field:\n                    sample_medium_sq.add(SQ(sample_mediums=sqs.query.clean(value)), SQ.OR)\n\n                elif 'units_names' in field:\n                    units_name_sq.add(SQ(units_names=sqs.query.clean(value)), SQ.OR)\n\n                else:\n                    continue\n\n        if author_sq:\n            sqs = sqs.filter(author_sq)\n        if subjects_sq:\n            sqs = sqs.filter(subjects_sq)\n        if resource_sq:\n            sqs = sqs.filter(resource_sq)\n        if public_sq:\n            sqs = sqs.filter(public_sq)\n        if owner_sq:\n            sqs = sqs.filter(owner_sq)\n        if discoverable_sq:\n            sqs = sqs.filter(discoverable_sq)\n        if published_sq:\n            sqs = sqs.filter(published_sq)\n        if variable_sq:\n            sqs = sqs.filter(variable_sq)\n        if sample_medium_sq:\n            sqs = sqs.filter(sample_medium_sq)\n        if units_name_sq:\n            sqs = sqs.filter(units_name_sq)\n\n        return sqs\n", "path": "hs_core/discovery_form.py"}], "after_files": [{"content": "from haystack.forms import FacetedSearchForm\nfrom haystack.query import SQ\nfrom django import forms\n\nclass DiscoveryForm(FacetedSearchForm):\n    NElat = forms.CharField(widget = forms.HiddenInput(), required=False)\n    NElng = forms.CharField(widget = forms.HiddenInput(), required=False)\n    SWlat = forms.CharField(widget = forms.HiddenInput(), required=False)\n    SWlng = forms.CharField(widget = forms.HiddenInput(), required=False)\n    start_date = forms.DateField(label='From Date', required=False)\n    end_date = forms.DateField(label='To Date', required=False)\n\n    def search(self):\n        if not self.cleaned_data.get('q'):\n            sqs = self.searchqueryset.filter(discoverable=True).filter(is_replaced_by=False)\n        else:\n            # This corrects for an failed match of complete words, as documented in issue #2308.\n            # The text__startswith=cdata matches stemmed words in documents with an unstemmed cdata.\n            # The text=cdata matches stemmed words after stemming cdata as well.\n            # The stem of \"Industrial\", according to the aggressive default stemmer, is \"industri\".\n            # Thus \"Industrial\" does not match \"Industrial\" in the document according to\n            # startswith, but does match according to text=cdata.\n            cdata = self.cleaned_data.get('q')\n            sqs = self.searchqueryset.filter(SQ(text__startswith=cdata)|SQ(text=cdata))\\\n                .filter(discoverable=True)\\\n                .filter(is_replaced_by=False)\n\n        geo_sq = SQ()\n        if self.cleaned_data['NElng'] and self.cleaned_data['SWlng']:\n            if float(self.cleaned_data['NElng']) > float(self.cleaned_data['SWlng']):\n                geo_sq.add(SQ(coverage_east__lte=float(self.cleaned_data['NElng'])), SQ.AND)\n                geo_sq.add(SQ(coverage_east__gte=float(self.cleaned_data['SWlng'])), SQ.AND)\n            else:\n                geo_sq.add(SQ(coverage_east__gte=float(self.cleaned_data['SWlng'])), SQ.AND)\n                geo_sq.add(SQ(coverage_east__lte=float(180)), SQ.OR)\n                geo_sq.add(SQ(coverage_east__lte=float(self.cleaned_data['NElng'])), SQ.AND)\n                geo_sq.add(SQ(coverage_east__gte=float(-180)), SQ.AND)\n\n        if self.cleaned_data['NElat'] and self.cleaned_data['SWlat']:\n            geo_sq.add(SQ(coverage_north__lte=float(self.cleaned_data['NElat'])), SQ.AND)\n            geo_sq.add(SQ(coverage_north__gte=float(self.cleaned_data['SWlat'])), SQ.AND)\n\n        if geo_sq:\n            sqs = sqs.filter(geo_sq)\n\n\n        # Check to see if a start_date was chosen.\n        if self.cleaned_data['start_date']:\n            sqs = sqs.filter(coverage_start_date__gte=self.cleaned_data['start_date'])\n\n        # Check to see if an end_date was chosen.\n        if self.cleaned_data['end_date']:\n            sqs = sqs.filter(coverage_end_date__lte=self.cleaned_data['end_date'])\n\n        author_sq = SQ()\n        subjects_sq = SQ()\n        resource_sq = SQ()\n        public_sq = SQ()\n        owner_sq = SQ()\n        discoverable_sq = SQ()\n        published_sq = SQ()\n        variable_sq = SQ()\n        sample_medium_sq = SQ()\n        units_name_sq = SQ()\n        # We need to process each facet to ensure that the field name and the\n        # value are quoted correctly and separately:\n\n        for facet in self.selected_facets:\n            if \":\" not in facet:\n                continue\n\n            field, value = facet.split(\":\", 1)\n\n            if value:\n                if \"creators\" in field:\n                    author_sq.add(SQ(creators=sqs.query.clean(value)), SQ.OR)\n\n                elif \"subjects\" in field:\n                    subjects_sq.add(SQ(subjects=sqs.query.clean(value)), SQ.OR)\n\n                elif \"resource_type\" in field:\n                    resource_sq.add(SQ(resource_type=sqs.query.clean(value)), SQ.OR)\n\n                elif \"public\" in field:\n                    public_sq.add(SQ(public=sqs.query.clean(value)), SQ.OR)\n\n                elif \"owners_names\" in field:\n                    owner_sq.add(SQ(owners_names=sqs.query.clean(value)), SQ.OR)\n\n                elif \"discoverable\" in field:\n                    discoverable_sq.add(SQ(discoverable=sqs.query.clean(value)), SQ.OR)\n\n                elif \"published\" in field:\n                    published_sq.add(SQ(published=sqs.query.clean(value)), SQ.OR)\n\n                elif 'variable_names' in field:\n                    variable_sq.add(SQ(variable_names=sqs.query.clean(value)), SQ.OR)\n\n                elif 'sample_mediums' in field:\n                    sample_medium_sq.add(SQ(sample_mediums=sqs.query.clean(value)), SQ.OR)\n\n                elif 'units_names' in field:\n                    units_name_sq.add(SQ(units_names=sqs.query.clean(value)), SQ.OR)\n\n                else:\n                    continue\n\n        if author_sq:\n            sqs = sqs.filter(author_sq)\n        if subjects_sq:\n            sqs = sqs.filter(subjects_sq)\n        if resource_sq:\n            sqs = sqs.filter(resource_sq)\n        if public_sq:\n            sqs = sqs.filter(public_sq)\n        if owner_sq:\n            sqs = sqs.filter(owner_sq)\n        if discoverable_sq:\n            sqs = sqs.filter(discoverable_sq)\n        if published_sq:\n            sqs = sqs.filter(published_sq)\n        if variable_sq:\n            sqs = sqs.filter(variable_sq)\n        if sample_medium_sq:\n            sqs = sqs.filter(sample_medium_sq)\n        if units_name_sq:\n            sqs = sqs.filter(units_name_sq)\n\n        return sqs\n", "path": "hs_core/discovery_form.py"}]}