Search Manager¶
-
class
elasticgit.search.
ESManager
(storage_manager, es, index_prefix)[source]¶ An interface to
elasticgit.models.Model
instances stored in Git.Parameters: - workspace (elasticgit.workspace.Workspace) – The workspace to operate on.
- es (elasticsearch.Elasticsearch) – An Elasticsearch client instance.
-
get_mapping
(name, model_class)[source]¶ Retrieve a mapping for a model class in a specific index
Parameters: - name (str) –
- model_class (elasticgit.models.Model) –
Returns: dict
-
index
(model, refresh_index=False)[source]¶ Index a
elasticgit.models.Model
instance in ElasticsearchParameters: - model (elasticgit.models.Model) – The model instance
- refresh_index (bool) – Whether or not to manually refresh the Elasticsearch index. Useful in testing.
Returns:
-
index_exists
(name)[source]¶ Check if the index already exists in Elasticsearch
Parameters: name (str) – Returns: bool
-
index_name
(name)[source]¶ Generate an Elasticsearch index name using given name and prefixing it with the
index_prefix
. The resulting generated index name is URL quoted.Parameters: name (str) – The name to use for the index.
-
raw_unindex
(model_class, uuid, refresh_index=False)[source]¶ Remove an entry from the Elasticsearch index. This differs from
unindex()
because it does not require an instance ofelasticgit.models.Model
because you’re likely in a position where you don’t have it if you’re trying to unindex it.Parameters: - model_class (elasticgit.models.Model) – The model class
- uuid (str) – The model’s UUID
- refresh_index (bool) – Whether or not to manually refresh the Elasticsearch index. Useful in testing.
-
refresh_indices
(name)[source]¶ Manually refresh the Elasticsearch index. In production this is not necessary but it is useful when running tests.
Parameters: name (str) –
-
setup_custom_mapping
(name, model_class, mapping)[source]¶ Specify a mapping for a model class in a specific index
Parameters: - name (str) –
- model_class (elasticgit.models.Model) –
- mapping (dict) – The Elasticsearch mapping definition
Returns: dict
-
setup_mapping
(name, model_class)[source]¶ Specify a mapping for a model class in a specific index
Parameters: - name (str) –
- model_class (elasticgit.models.Model) –
Returns: dict
-
unindex
(model, refresh_index=False)[source]¶ Remove a
elasticgit.models.Model
instance from the Elasticsearch index.Parameters: - model (elasticgit.models.Model) – The model instance
- refresh_index (bool) – Whether or not to manually refresh the Elasticsearch index. Useful in testing.
Returns: