Indices

Object to deal with ES indices as they are used in the PAW.

class elasticwrap.indices.IndicesWrapper(*args, **kwargs)

Bases: IndicesClient

Object to deal with ES indices as they are used in the PAW.

See also

elasticsearch.client.IndicesClient

Notes

Has some underlying assumptions about how indices are named and what their purpose is. If indices are called differently, you can still use this object by using the vanilla ES methods, but most methods are not made with it in mind.

It is assumed that all SIGmoirelab created indices will follow the structure {proj_name}_{source}. I.E. FooCo_git.

logger

A specific logger for this object

create_index(proj: str, source: str)

Creates an index for a certain project and source.

Parameters
  • proj (str) – The project name

  • source (str) – The source name

delete_indices_of_project(proj: str)

Delete all indices belonging to a certain project.

Parameters

proj (str) – The project to delete the indices of

get_all_indices() List[str]

List all the indices.

Returns

A list of all indices

Return type

list[str]

get_current_kibana() Optional[str]

Tries to determine what the current kibana index is.

Returns

The current kibana index, or None if there is none.

Return type

Optional[str]

Notes

If there are multiple indices, a warning will be logged and the first will be returned.

get_indices_of_project(proj: str) str

Returns all the indices that belong to a specific project.

Parameters

proj (str) – The project to which the indices should belong.

Returns

A comma separated list of indices that belong to this project.

Return type

str

get_indices_of_source(source: str) str

Returns all the indices that belong to a specific data source.

Parameters

source (str) – The data source to which the indices should belong.

Returns

A comma separated list of indices that belong to this data source.

Return type

str

search_indices(query: str) str

Find all indices matching a certain query string.

Parameters

query (str) – The query to search with.

Returns

All the indices that match the query. Comma separated as ES expects.

Return type

str

See also

_search_indices

Returns indices in a list instead of a comma separated string