search.integration
¶
Module Contents¶
Classes¶
A transport class that is less eager to rejoin connections when there's |
|
Provides elasticsearch integration for |
Functions¶
|
|
- class search.integration.TolerantTransport(*args: Any, **kwargs: Any)[source]¶
Bases:
elasticsearch.Transport
A transport class that is less eager to rejoin connections when there’s a failure. Additionally logs all Elasticsearch transport errors in one location.
- class search.integration.ElasticsearchApp[source]¶
Bases:
morepath.App
Provides elasticsearch integration for
onegov.core.framework.Framework
based applications.The application must be connected to a database.
Usage:
from onegov.core import Framework class MyApp(Framework, ESIntegration): pass
- configure_search(**cfg: Any) None [source]¶
Configures the elasticsearch client, leaving it as a property on the class:
app.es_client
The following configuration options are accepted:
- Enable_elasticsearch:
If True, elasticsearch is enabled (defaults to True).
- Elasticsearch_hosts:
A list of elasticsearch clusters, including username, password, protocol and port.
For example:
https://user:secret@localhost:443
By default the client connects to the localhost on port 9200 (the default), and on port 19200 (the default of boxen).
At least one host in the list of servers must be up at startup.
- Elasticsearch_may_queue_size:
The maximum queue size reserved for documents to be indexed. This queue is filling up if the elasticsearch cluster cannot be reached.
Once the queue is full, warnings are emitted.
Defaults to 10’000
- Elasticsearch_verify_certs:
If true, the elasticsearch client verifies the certificates of the ssl connection. Defaults to true. Do not disable, unless you are in testing!
- Elasticsearch_languages:
- The languages supported by onegov.search. Defaults to:
en
de
fr
- es_search(languages: Iterable[str] = '*', types: Iterable[str] = '*', include_private: bool = False, explain: bool = False) onegov.search.Search [source]¶
Returns a search scoped to the current application, with the given languages, types and private documents excluded by default.
- es_search_by_request(request: onegov.core.request.CoreRequest, types: Iterable[str] = '*', explain: bool = False, limit_to_request_language: bool = False) onegov.search.Search [source]¶
Takes the current
CoreRequest
and returns an elastic search scoped to the current application, the requests language and it’s access rights.
- es_suggestions(query: str, languages: Iterable[str] = '*', types: Iterable[str] = '*', include_private: bool = False) tuple[str, Ellipsis] [source]¶
Returns suggestions for the given query.
- es_suggestions_by_request(request: onegov.core.request.CoreRequest, query: str, types: Iterable[str] = '*', limit_to_request_language: bool = False) tuple[str, Ellipsis] [source]¶
Returns suggestions for the given query, scoped to the language and the login status of the given requst.
- search.integration.process_indexer_tween_factory(app: ElasticsearchApp, handler: Callable[[CoreRequest], Response]) Callable[[CoreRequest], Response] [source]¶