search.mixins
Classes
Defines the interface required for an object to be searchable. |
|
Extends the default |
|
Adds search to all classes using the core's content mixin: |
Module Contents
- class search.mixins.Searchable[source]
Defines the interface required for an object to be searchable.
Note that
fts_id `` and ``fts_properties
must be class properties, not instance properties. So do this:class X(Searchable): fts_properties = {}
But do not do this:
class X(Searchable): @property def fts_properties(self): return {}
The rest of the properties may be normal properties.
- classmethod fts_id() str [source]
- Abstractmethod:
The name of the id attribute (not the actual value!).
If you use this on an ORM model, be sure to use a primary key, all other properties are not available during deletion.
- property fts_language: str[source]
Defines the language of the object. By default ‘auto’ is used, which triggers automatic language detection. Automatic language detection is reasonably accurate if provided with enough text. Short texts are not detected easily.
When ‘auto’ is used, expect some content to be misclassified. You should then search over all languages, not just the expected one.
This property can be used to manually set the language.
- property fts_public: bool[source]
- Abstractmethod:
Returns True if the model is available to be found by the public. If false, only editors/admins will see this object in the search results.
- property fts_skip: bool[source]
Returns True if the indexing of this specific model instance should be skipped.
- property fts_suggestion: collections.abc.Sequence[str] | str[source]
Returns suggest-as-you-type value of the document. The field used for this property should also be indexed, or the suggestion will lead to nowhere.
If a single string is returned, the completion input equals the completion output. (My Title -> My Title)
If an array of strings is returned, all values are possible inputs and the first value is the output. (My Title/Title My -> My Title)
- property fts_publication_start: datetime.datetime | None[source]
Returns the date when the document should become public.
- property fts_publication_end: datetime.datetime | None[source]
Returns the date when the document should stop being public.
- class search.mixins.ORMSearchable[source]
Bases:
Searchable
Extends the default
Searchable
class with sensible defaults for SQLAlchemy orm models.
- class search.mixins.SearchableContent[source]
Bases:
ORMSearchable
Adds search to all classes using the core’s content mixin:
onegov.core.orm.mixins.content.ContentMixin