morpheus.controllers.elasticsearch_controller.ElasticsearchController#
- class ElasticsearchController(
- connection_kwargs,
- raise_on_exception=False,
- refresh_period_secs=2400,
Bases:
objectElasticsearchController to perform read and write operations using Elasticsearch service.
- Parameters:
- connection_kwargsdict
Keyword arguments to configure the Elasticsearch connection.
- raise_on_exceptionbool, optional, default: False
Whether to raise exceptions on Elasticsearch errors.
- refresh_period_secsint, optional, default: 2400
The refresh period in seconds for client refreshing.
Methods
Close the Elasticsearch client connection.
df_to_parallel_bulk_write(index, df)Converts DataFrames to actions and parallel bulk writes to Elasticsearch.
parallel_bulk_write(actions)Perform parallel bulk writes to Elasticsearch.
refresh_client([force])Refresh the Elasticsearch client instance.
search_documents(index, query, **kwargs)Search for documents in Elasticsearch based on the given query.
- df_to_parallel_bulk_write(index, df)[source]#
Converts DataFrames to actions and parallel bulk writes to Elasticsearch.
- Parameters:
- indexstr
The name of the index to write.
- dfpd.DataFrame
DataFrame entries that require writing to Elasticsearch.
- parallel_bulk_write(actions)[source]#
Perform parallel bulk writes to Elasticsearch.
- Parameters:
- actionslist
List of actions to perform in parallel.
- refresh_client(force=False)[source]#
Refresh the Elasticsearch client instance.
- Parameters:
- forcebool, optional, default: False
Force a client refresh.
- Returns:
- bool
Returns true if client is refreshed, otherwise false.
- search_documents(index, query, **kwargs)[source]#
Search for documents in Elasticsearch based on the given query.
- Parameters:
- indexstr
The name of the index to search.
- querydict
The DSL query for the search.
- **kwargs
Additional keyword arguments that are supported by the Elasticsearch search method.
- Returns:
- dict
The search result returned by Elasticsearch.