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:
-
class
elasticgit.search.
SM
(model_class, in_, index_prefixes=None)[source]¶ A search interface similar to
elasticutils.S
to retrieveelasticgit.search.ReadOnlyModelMappingType
instances stored in Elasticsearch. These can be converted toelasticgit.model.Model
instances usingReadOnlyModelMappingType.to_object()
.Parameters: - model_class (type) – A subclass of
elasticgit.models.Model
for generating a mapping type. - in (list) – A list of
git.Repo
instances, or a list of repo working dirs. - index_prefixes (list) – An optional list of index prefixes corresponding to the repos in in_.
- model_class (type) – A subclass of