API documentation

The API is accessible through a proxy object that points to the api.TaxonomyESAPI class. Here’s how to call each API method:

current_flask_taxonomies_es.<method>(parameters)
class flask_taxonomies_es.api.TaxonomyESAPI(app)

Constructor takes Flask app as parameter. However, it is not necessary create class instance. Class instance should be called with proxy method: current_flask_taxonomies_es.

get(taxonomy_code: str, slug: str)

Return serialized taxonomy term. Takes taxonomy code and slug as strings.

Parameters

slug (str) –

Returns

Serialized taxonomy term as dict

Return type

dict

get_ref(taxonomy_url: str)

Like the get method, it returns a serialized taxonomy. Instead of taxonomy and slug it takes the url as an argument.

Parameters

taxonomy_url (str) – taxonomy term url, could be absolute or relative.

Returns

Serialized taxonomy term as dict

Return type

dict

list(taxonomy_code: str) → list

Returns list of taxonomy terms. Individual records are serialized taxonomy terms.

Parameters

taxonomy_code (str) – Code of taxonomy.

Returns

List of serialized (dict) taxonomy terms

Return type

list

reindex(taxonomies: flask_taxonomies_es.api.TaxonomyESAPI.list = None) → datetime.datetime

Reindex taxonomy index. Update taxonomy term and remove obsolete taxonomy terms.

Returns

UTC timestamp

Return type

datetime

remove(taxonomy_term: flask_taxonomies.models.TaxonomyTerm = None, taxonomy_code: str = None, slug: str = None) → None

Remove taxonomy term from elasticsearch index. It takes either TaxonomyTerm class or taxonomy code with slug as strings.

Parameters
  • taxonomy_term (TaxonomyTerm) – Taxonomy term class from flask-taxonomies

  • taxonomy_code (str) – Code of taxonomy.

  • slug (str) – Taxonomy slug as string

Returns

None

Return type

None

search(query: elasticsearch_dsl.query.Q, match=False)

The method returns elasticsearch search results, taking the Q query from elasticsearch-dsl as a parameter.

Parameters

query`<https://elasticsearch-dsl.readthedocs.io/en/latest/search_dsl.html

#queries>`_ :type query: elasticsearch_dsl.Q :return: list of jsonify results :rtype: list

set(taxonomy_term: flask_taxonomies.models.TaxonomyTerm, timestamp=None) → None

Save serialized taxonomy into Elasticsearch. It create new or update old taxonomy record.

Parameters
  • taxonomy_term (TaxonomyTerm) – Taxonomy term class from flask-taxonomies

  • timestamp (Datetime class) – Datetime class

Returns

None

Return type

None