Jump to >

reviewboard.search.search_backends.base

The base search backend classes.

class SearchBackendForm(*args, **kwargs)[source]

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.

class SearchBackend[source]

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.

search_backend_id = None[source]

The search engine’s unique identifier.

name = None[source]

The human-readable name for the search engine.

haystack_backend_name = None[source]

The name of the Haystack search engine backend.

config_form_class = None[source]

The configuration form class for the search engine.

default_settings = {}[source]

The default search engine settings.

form_field_map = {}[source]

A mapping of search engine settings to form fields.

property 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

load_haystack_engine(**kwargs)[source]

Load the Haystack backend engine.

This will construct the engine with the provided parameters. A new instance will be constructed every time this is called.

Parameters

**kwargs (dict) – Keyword arguments to pass to the engine constructor.

Returns

The resulting engine instance.

Return type

django_haystack.backends.BaseEngine

validate(configuration, **kwargs)[source]

Validate the settings and dependencies for the search backend.

This will perform a test search to ensure the configuration works.

Subclasses can override this to perform other checks that may be required (such as checking for a suitable module). They should call the parent method in order to perform a test search using the configured settings.

Changed in version 4.0.5: Added the configuration and **kwargs arguments. Subclasses msut be updated to take **kwargs.

Raises

django.core.exceptions.ValidationError – Backend configuration, supporting modules, or the test search failed.

get_config_form(data=None, **kwargs)[source]

Create and return a new configuration form instance.

The returned form will have a prefix of the search engine ID.

Parameters
  • data (dict, optional) – The form data.

  • **kwargs (dict) – Additional keyword arguments to pass to the form.

Returns

The instantiated form class.

Return type

SearchBackendForm