Search Manager

class elasticgit.search.ESManager(storage_manager, es, index_prefix)[source]

An interface to elasticgit.models.Model instances stored in Git.

Parameters:
create_index(name)[source]

Creates the index in Elasticsearch

Parameters:name (str) –
destroy_index(name)[source]

Destroys the index in Elasticsearch

Parameters:name (str) –
get_mapping(name, model_class)[source]

Retrieve a mapping for a model class in a specific index

Parameters:
Returns:

dict

index(model, refresh_index=False)[source]

Index a elasticgit.models.Model instance in Elasticsearch

Parameters:
  • model (elasticgit.models.Model) – The model instance
  • refresh_index (bool) – Whether or not to manually refresh the Elasticsearch index. Useful in testing.
Returns:

elasticgit.models.Model

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.
index_ready(name)[source]

Check if an index is ready for use.

Parameters:name (str) –
Returns:bool
index_status(name)[source]

Get an index status

Parameters:name (str) –
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 of elasticgit.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:
Returns:

dict

setup_mapping(name, model_class)[source]

Specify a mapping for a model class in a specific index

Parameters:
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:

elasticgit.models.Model