reviewboard.search.search_backends.base¶
The base search backend classes.
-
class
SearchBackendForm
(*args, **kwargs)[source]¶ Bases:
django.forms.forms.Form
A search backend configuration form.
This form allows the configuration of a Haystack backend to be configured from the admin interface and reloaded on the fly.
-
__init__
(*args, **kwargs)[source]¶ Initialize the backend.
Parameters: request (django.http.HttpRequest) – The current HTTP request.
-
-
class
SearchBackend
[source]¶ Bases:
object
A search backend.
A SearchBackend is a wrapper around a Haystack backend that has methods for getting and setting per-backend configuration. This allows the backend to be configured at runtime and live reloaded, instead of having them hardcoded in
settings.py
.-
configuration
[source]¶ The configuration for the search engine.
Returns: The configuration for the search engine. Return type: dict
-
get_configuration_from_form_data
(form_data)[source]¶ Return the configuration from the form’s data.
- Args:
- form_data (dict):
- The form data.
Returns: The search engine configuration. Return type: dict
-
get_form_data
()[source]¶ Return the form data for the current configuration.
Returns: The search engine form data. Return type: dict
-
validate
()[source]¶ Validate any non-form prerequisites for using the backend.
Subclasses should attempt to import any required modules and, if they cannot be imported (i.e., an
ImportError
is raised), then adjango.core.exceptions.ValidationError
should be raised indicating the failure to load the module.For example, the
ElasticsearchSearchBackend
requires theelasticsearch
module to be available.Raises: django.core.exceptions.ValidationError
– Raised if a required module is missing.
-