Computed fields

One of the most common use of a computed field is to generate document's slug. A document's slug is a human readable and url friendly string used to identify a document within an url. Typically we'll use the document's title fields to generate a slug:

  • Welcome at elasticms ⇒ welcome-at-elasticms
  • Poème du soir ⇒ poeme-du-soir

In this example we are generating a English slug for the document base on the document's English title. Except if it's the homepage (identified by it's OUUID), in that case the document's will be forced to 'homepage':

{% spaceless %}
{% if _id == 'AWyHygh6rkMnt-6uAUvY' %}
{% else %}
   { _source.title_en|url_generator }}
{% endif %}
{% endspaceless %}

The computed field's 'Value template' field accepts the same parameters than a regular post-processing field:

  • _source: associative array of the document's data
  • _type: name (string) of the document's content type
  • _id: OUUID (string) of the document
  • index: elasticsearch alias (string) of the environment
  • migration: boolean set the true if the run is in the context of a migration of content
  • parent: associative array of the field's parent document's data
  • path: elasticsearch path field