prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  search fields can't be overridden
  In the past, you were able to override a search field of a parent class by redefining it. This functionality appears to be broken in Wagtail 0.7
  
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `wagtail/wagtailsearch/index.py`
  Content:
  ```
  1 import warnings
  2 
  3 from six import string_types
  4 
  5 from django.db import models
  6 
  7 
  8 class Indexed(object):
  9     @classmethod
  10     def indexed_get_parent(cls, require_model=True):
  11         for base in cls.__bases__:
  12             if issubclass(base, Indexed) and (issubclass(base, models.Model) or require_model is False):
  13                 return base
  14 
  15     @classmethod
  16     def indexed_get_content_type(cls):
  17         # Work out content type
  18         content_type = (cls._meta.app_label + '_' + cls.__name__).lower()
  19 
  20         # Get parent content type
  21         parent = cls.indexed_get_parent()
  22         if parent:
  23             parent_content_type = parent.indexed_get_content_type()
  24             return parent_content_type + '_' + content_type
  25         else:
  26             return content_type
  27 
  28     @classmethod
  29     def indexed_get_toplevel_content_type(cls):
  30         # Get parent content type
  31         parent = cls.indexed_get_parent()
  32         if parent:
  33             return parent.indexed_get_content_type()
  34         else:
  35             # At toplevel, return this content type
  36             return (cls._meta.app_label + '_' + cls.__name__).lower()
  37 
  38     @classmethod
  39     def get_search_fields(cls):
  40         return cls.search_fields
  41 
  42     @classmethod
  43     def get_searchable_search_fields(cls):
  44         return filter(lambda field: isinstance(field, SearchField), cls.get_search_fields())
  45 
  46     @classmethod
  47     def get_filterable_search_fields(cls):
  48         return filter(lambda field: isinstance(field, FilterField), cls.get_search_fields())
  49 
  50     @classmethod
  51     def get_indexed_objects(cls):
  52         return cls.objects.all()
  53 
  54     search_fields = ()
  55 
  56 
  57 class BaseField(object):
  58     suffix = ''
  59 
  60     def __init__(self, field_name, **kwargs):
  61         self.field_name = field_name
  62         self.kwargs = kwargs
  63 
  64     def get_field(self, cls):
  65         return cls._meta.get_field_by_name(self.field_name)[0]
  66 
  67     def get_attname(self, cls):
  68         try:
  69             field = self.get_field(cls)
  70             return field.attname
  71         except models.fields.FieldDoesNotExist:
  72             return self.field_name
  73 
  74     def get_index_name(self, cls):
  75         return self.get_attname(cls) + self.suffix
  76 
  77     def get_type(self, cls):
  78         if 'type' in self.kwargs:
  79             return self.kwargs['type']
  80 
  81         try:
  82             field = self.get_field(cls)
  83             return field.get_internal_type()
  84         except models.fields.FieldDoesNotExist:
  85             return 'CharField'
  86 
  87     def get_value(self, obj):
  88         try:
  89             field = self.get_field(obj.__class__)
  90             return field._get_val_from_obj(obj)
  91         except models.fields.FieldDoesNotExist:
  92             value = getattr(obj, self.field_name, None)
  93             if hasattr(value, '__call__'):
  94                 value = value()
  95             return value
  96 
  97     def __repr__(self):
  98         return '<%s: %s>' % (self.__class__.__name__, self.field_name)
  99 
  100 
  101 class SearchField(BaseField):
  102     def __init__(self, field_name, boost=None, partial_match=False, **kwargs):
  103         super(SearchField, self).__init__(field_name, **kwargs)
  104         self.boost = boost
  105         self.partial_match = partial_match
  106 
  107 
  108 class FilterField(BaseField):
  109     suffix = '_filter'
  110 
  111
  ```
  --- 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/wagtail/wagtailsearch/index.py b/wagtail/wagtailsearch/index.py
  --- a/wagtail/wagtailsearch/index.py
  +++ b/wagtail/wagtailsearch/index.py
  @@ -37,15 +37,26 @@
   
       @classmethod
       def get_search_fields(cls):
  -        return cls.search_fields
  +        search_fields = {}
  +
  +        for field in cls.search_fields:
  +            search_fields[(type(field), field.field_name)] = field
  +
  +        return list(search_fields.values())
   
       @classmethod
       def get_searchable_search_fields(cls):
  -        return filter(lambda field: isinstance(field, SearchField), cls.get_search_fields())
  +        return [
  +            field for field in cls.get_search_fields()
  +            if isinstance(field, SearchField)
  +        ]
   
       @classmethod
       def get_filterable_search_fields(cls):
  -        return filter(lambda field: isinstance(field, FilterField), cls.get_search_fields())
  +        return [
  +            field for field in cls.get_search_fields()
  +            if isinstance(field, FilterField)
  +        ]
   
       @classmethod
       def get_indexed_objects(cls):
  
verification_info: {"golden_diff": "diff --git a/wagtail/wagtailsearch/index.py b/wagtail/wagtailsearch/index.py\n--- a/wagtail/wagtailsearch/index.py\n+++ b/wagtail/wagtailsearch/index.py\n@@ -37,15 +37,26 @@\n \n     @classmethod\n     def get_search_fields(cls):\n-        return cls.search_fields\n+        search_fields = {}\n+\n+        for field in cls.search_fields:\n+            search_fields[(type(field), field.field_name)] = field\n+\n+        return list(search_fields.values())\n \n     @classmethod\n     def get_searchable_search_fields(cls):\n-        return filter(lambda field: isinstance(field, SearchField), cls.get_search_fields())\n+        return [\n+            field for field in cls.get_search_fields()\n+            if isinstance(field, SearchField)\n+        ]\n \n     @classmethod\n     def get_filterable_search_fields(cls):\n-        return filter(lambda field: isinstance(field, FilterField), cls.get_search_fields())\n+        return [\n+            field for field in cls.get_search_fields()\n+            if isinstance(field, FilterField)\n+        ]\n \n     @classmethod\n     def get_indexed_objects(cls):\n", "issue": "search fields can't be overridden\nIn the past, you were able to override a search field of a parent class by redefining it. This functionality appears to be broken in Wagtail 0.7\n\n", "before_files": [{"content": "import warnings\n\nfrom six import string_types\n\nfrom django.db import models\n\n\nclass Indexed(object):\n    @classmethod\n    def indexed_get_parent(cls, require_model=True):\n        for base in cls.__bases__:\n            if issubclass(base, Indexed) and (issubclass(base, models.Model) or require_model is False):\n                return base\n\n    @classmethod\n    def indexed_get_content_type(cls):\n        # Work out content type\n        content_type = (cls._meta.app_label + '_' + cls.__name__).lower()\n\n        # Get parent content type\n        parent = cls.indexed_get_parent()\n        if parent:\n            parent_content_type = parent.indexed_get_content_type()\n            return parent_content_type + '_' + content_type\n        else:\n            return content_type\n\n    @classmethod\n    def indexed_get_toplevel_content_type(cls):\n        # Get parent content type\n        parent = cls.indexed_get_parent()\n        if parent:\n            return parent.indexed_get_content_type()\n        else:\n            # At toplevel, return this content type\n            return (cls._meta.app_label + '_' + cls.__name__).lower()\n\n    @classmethod\n    def get_search_fields(cls):\n        return cls.search_fields\n\n    @classmethod\n    def get_searchable_search_fields(cls):\n        return filter(lambda field: isinstance(field, SearchField), cls.get_search_fields())\n\n    @classmethod\n    def get_filterable_search_fields(cls):\n        return filter(lambda field: isinstance(field, FilterField), cls.get_search_fields())\n\n    @classmethod\n    def get_indexed_objects(cls):\n        return cls.objects.all()\n\n    search_fields = ()\n\n\nclass BaseField(object):\n    suffix = ''\n\n    def __init__(self, field_name, **kwargs):\n        self.field_name = field_name\n        self.kwargs = kwargs\n\n    def get_field(self, cls):\n        return cls._meta.get_field_by_name(self.field_name)[0]\n\n    def get_attname(self, cls):\n        try:\n            field = self.get_field(cls)\n            return field.attname\n        except models.fields.FieldDoesNotExist:\n            return self.field_name\n\n    def get_index_name(self, cls):\n        return self.get_attname(cls) + self.suffix\n\n    def get_type(self, cls):\n        if 'type' in self.kwargs:\n            return self.kwargs['type']\n\n        try:\n            field = self.get_field(cls)\n            return field.get_internal_type()\n        except models.fields.FieldDoesNotExist:\n            return 'CharField'\n\n    def get_value(self, obj):\n        try:\n            field = self.get_field(obj.__class__)\n            return field._get_val_from_obj(obj)\n        except models.fields.FieldDoesNotExist:\n            value = getattr(obj, self.field_name, None)\n            if hasattr(value, '__call__'):\n                value = value()\n            return value\n\n    def __repr__(self):\n        return '<%s: %s>' % (self.__class__.__name__, self.field_name)\n\n\nclass SearchField(BaseField):\n    def __init__(self, field_name, boost=None, partial_match=False, **kwargs):\n        super(SearchField, self).__init__(field_name, **kwargs)\n        self.boost = boost\n        self.partial_match = partial_match\n\n\nclass FilterField(BaseField):\n    suffix = '_filter'\n\n", "path": "wagtail/wagtailsearch/index.py"}], "after_files": [{"content": "import warnings\n\nfrom six import string_types\n\nfrom django.db import models\n\n\nclass Indexed(object):\n    @classmethod\n    def indexed_get_parent(cls, require_model=True):\n        for base in cls.__bases__:\n            if issubclass(base, Indexed) and (issubclass(base, models.Model) or require_model is False):\n                return base\n\n    @classmethod\n    def indexed_get_content_type(cls):\n        # Work out content type\n        content_type = (cls._meta.app_label + '_' + cls.__name__).lower()\n\n        # Get parent content type\n        parent = cls.indexed_get_parent()\n        if parent:\n            parent_content_type = parent.indexed_get_content_type()\n            return parent_content_type + '_' + content_type\n        else:\n            return content_type\n\n    @classmethod\n    def indexed_get_toplevel_content_type(cls):\n        # Get parent content type\n        parent = cls.indexed_get_parent()\n        if parent:\n            return parent.indexed_get_content_type()\n        else:\n            # At toplevel, return this content type\n            return (cls._meta.app_label + '_' + cls.__name__).lower()\n\n    @classmethod\n    def get_search_fields(cls):\n        search_fields = {}\n\n        for field in cls.search_fields:\n            search_fields[(type(field), field.field_name)] = field\n\n        return list(search_fields.values())\n\n    @classmethod\n    def get_searchable_search_fields(cls):\n        return [\n            field for field in cls.get_search_fields()\n            if isinstance(field, SearchField)\n        ]\n\n    @classmethod\n    def get_filterable_search_fields(cls):\n        return [\n            field for field in cls.get_search_fields()\n            if isinstance(field, FilterField)\n        ]\n\n    @classmethod\n    def get_indexed_objects(cls):\n        return cls.objects.all()\n\n    search_fields = ()\n\n\nclass BaseField(object):\n    suffix = ''\n\n    def __init__(self, field_name, **kwargs):\n        self.field_name = field_name\n        self.kwargs = kwargs\n\n    def get_field(self, cls):\n        return cls._meta.get_field_by_name(self.field_name)[0]\n\n    def get_attname(self, cls):\n        try:\n            field = self.get_field(cls)\n            return field.attname\n        except models.fields.FieldDoesNotExist:\n            return self.field_name\n\n    def get_index_name(self, cls):\n        return self.get_attname(cls) + self.suffix\n\n    def get_type(self, cls):\n        if 'type' in self.kwargs:\n            return self.kwargs['type']\n\n        try:\n            field = self.get_field(cls)\n            return field.get_internal_type()\n        except models.fields.FieldDoesNotExist:\n            return 'CharField'\n\n    def get_value(self, obj):\n        try:\n            field = self.get_field(obj.__class__)\n            return field._get_val_from_obj(obj)\n        except models.fields.FieldDoesNotExist:\n            value = getattr(obj, self.field_name, None)\n            if hasattr(value, '__call__'):\n                value = value()\n            return value\n\n    def __repr__(self):\n        return '<%s: %s>' % (self.__class__.__name__, self.field_name)\n\n\nclass SearchField(BaseField):\n    def __init__(self, field_name, boost=None, partial_match=False, **kwargs):\n        super(SearchField, self).__init__(field_name, **kwargs)\n        self.boost = boost\n        self.partial_match = partial_match\n\n\nclass FilterField(BaseField):\n    suffix = '_filter'\n\n", "path": "wagtail/wagtailsearch/index.py"}]}