reviewboard.search.indexes¶
- class BaseSearchIndex[source]¶
Bases:
Generic[_TModel],SearchIndexBase class for a search index.
This sets up a few common fields we want all indexes to include.
Changed in version 8.0: This now supports a generic type for the indexed model.
- local_site_attr: str | None = None¶
The local site attribute on the model.
For ForeignKeys, this should be the name of the ID field, as in ‘local_site_id’. For ManyToManyFields, it should be the standard field name.
- get_model() type[_TModel][source]¶
Return the model for this index.
- Returns:
The type of model.
- Return type:
- Raises:
AttributeError –
modelwas not set on the subclass.
- prepare_local_sites(obj: _TModel) Sequence[str][source]¶
Prepare the list of local sites for the search index.
This will take any associated local sites on the object and store them in the index as a list. The search view can then easily look up values in the list, regardless of the type of object.
If the object is not a part of a local site, the list will be
[0], indicating no local site.- Parameters:
obj (
django.db.models.Model) – The model instance to prepare.- Returns:
The list of of model Local Site IDs as strings, or
[0]if there are no Local Sites.- Return type:
- Raises:
django.core.exceptions.ImproperlyConfigured – One or more attributes were not set on the subclass.
- fields = {'local_sites': <haystack.fields.MultiValueField object>, 'text': <haystack.fields.CharField object>}¶
- objects = <haystack.manager.SearchIndexManager object>¶