search.utils
Attributes
Classes
Abstract base class for generic types. |
|
Detects languages with the help of langdetect. |
Functions
|
Searches through the given SQLAlchemy base and returns the classes |
|
Checks if the given name is a valid elasticsearch index name. |
|
|
|
|
|
|
|
|
|
|
|
Gathers all related es type names from the given model. A type is |
Module Contents
- search.utils.searchable_sqlalchemy_models(base: type[T]) Iterator[type[Searchable]] [source]
Searches through the given SQLAlchemy base and returns the classes of all SQLAlchemy models found which inherit from the
onegov.search.mixins.Searchable
interface.
- search.utils.is_valid_index_name(name: str) bool [source]
Checks if the given name is a valid elasticsearch index name. Elasticsearch does it’s own checks, but we can do it earlier and we are a bit stricter.
- class search.utils.classproperty(f: Callable[[type[Any]], T_co])[source]
Bases:
Generic
[T_co
]Abstract base class for generic types.
A generic type is typically declared by inheriting from this class parameterized with one or more type variables. For example, a generic mapping type might be defined as:
class Mapping(Generic[KT, VT]): def __getitem__(self, key: KT) -> VT: ... # Etc.
This class can then be used as follows:
def lookup_name(mapping: Mapping[KT, VT], key: KT, default: VT) -> VT: try: return mapping[key] except KeyError: return default
Gathers all related es type names from the given model. A type is counted as related a model is part of a polymorphic setup.
If no polymorphic identity is found, the result is simply a set with the model’s type itself.