# Pivot Templates

Source: https://zotonic.com/cookbook/1282/pivot-templates

URI: https://zotonic.com/id/1282

Language: en



<div>
            
  <div class="section">

<p><a class="reference internal" href="/id/1638#guide-datamodel-query-model"><span class="std std-ref">Search</span></a> uses database indices on special pivot
columns and full text fields.</p>
<p>These columns and text fields are extracted in a process called <em>pivoting</em>.
This is done a short period after a resource has been updated.</p>
<p>The content of the pivot columns is determined by a template. This template is
called <code class="docutils literal notranslate"><span class="pre">pivot/pivot.tpl</span></code> (in <code class="docutils literal notranslate"><span class="pre">mod_base</span></code>) and is rendered using a <em>catinclude</em>.
This makes it possible to have your own unique indexing per category.</p>
<p>The <code class="docutils literal notranslate"><span class="pre">pivot/pivot.tpl</span></code> template consists of multiple blocks. Each block corresponds
to a pivot column. The block is rendered for determining the pivot’s content.</p>
<p>The following blocks are defined:</p>
<p><strong>a, b, c and d</strong></p>

<p>These blocks are used for the full text index. Block <em>a</em> contains more
important texts than block <em>b</em>, <em>c</em> or <em>d</em>. Per default the title and other
essential texts are shown in block <em>a</em>, and block <em>d</em> is used for related
texts (think titles of connected resources).
The default pivot template uses the following catincluded templates for the
different blocks:

<ul class="simple">
<li><code class="docutils literal notranslate"><span class="pre">pivot/_title_text.tpl</span></code> for block <em>a</em></li>
<li><code class="docutils literal notranslate"><span class="pre">pivot/_main_text.tpl</span></code> for block <em>b</em></li>
<li><code class="docutils literal notranslate"><span class="pre">pivot/_block_text.tpl</span></code> for block <em>c</em></li>
<li><code class="docutils literal notranslate"><span class="pre">pivot/_related_text.tpl</span></code> for block <em>d</em></li>
</ul>

</p>
<p><strong>title</strong></p>

<p>The title used for database sorting etc. Per default the lowercased title in the selected
pivot language or the default site language.</p>
<p><strong>related_ids</strong></p>

<p>The ids of all related resources and categories. This is a full text index used for
finding resources that are similar to some other resource.
All matching resource ids should be prefixed with <code class="docutils literal notranslate"><span class="pre">zpo</span></code> and category ids with <code class="docutils literal notranslate"><span class="pre">zpc</span></code>
(for example <code class="docutils literal notranslate"><span class="pre">zpo1234</span></code>).
The catincluded template <code class="docutils literal notranslate"><span class="pre">pivot/_related_ids.tpl</span></code> is used for extracting these ids.
This template also adds the id of the content group as a related resource.
</p>
<p><strong>address_street, address_city, address_postcode, address_state, address_country</strong></p>

<p>The address to be used for searches. Defaults to the related <code class="docutils literal notranslate"><span class="pre">address_…</span></code> properties
with a fallback to the <code class="docutils literal notranslate"><span class="pre">mail_address_…</span></code> properties.
The country should be the two letter ISO code, not the country’s descriptive text.
</p>
<p><strong>name_first, name_surname</strong></p>

<p>If the resource is a person then this should contain the first name and surname.</p>
<p><strong>gender</strong></p>

<p>The gender of the person, currently a single letter.  For example: <code class="docutils literal notranslate"><span class="pre">f</span></code>, <code class="docutils literal notranslate"><span class="pre">m</span></code> or <code class="docutils literal notranslate"><span class="pre">?</span></code>.</p>
<p><strong>date_start, date_end</strong></p>

<p>The start or end date associated with the resource. This should be in a parseable format, which
will be done automatically when echoing a date directly. Make sure UTC is used as the timezone (note that the timezone will be set to UTC when pivoting).</p>
<p><strong>date_start_month_day, date_end_month_day</strong></p>

<p>A four digit number representing the month and day for the date start and date end. Think of
an index for birthdays, without exposing the birth year.
Defaults to <code class="docutils literal notranslate"><span class="pre">{{</span> <span class="pre">id.date_start|date:"md"</span> <span class="pre">}}</span></code> and <code class="docutils literal notranslate"><span class="pre">{{</span> <span class="pre">id.date_end|date:"md"</span> <span class="pre">}}</span></code>.
</p>
<p><strong>location_lat, location_lng</strong></p>

<p>The latitude and longitude of the resource location. This should be empty or a floating point number.
Defaults to <code class="docutils literal notranslate"><span class="pre">{{</span> <span class="pre">id.computed_location_lat|default:id.location_lat</span> <span class="pre">}}</span></code> and <code class="docutils literal notranslate"><span class="pre">{{</span> <span class="pre">id.computed_location_lng|default:id.location_lng</span> <span class="pre">}}</span></code>
</p>
<p><strong>date_repivot</strong></p>

<p>The date and time this resource should be repivoted. This is useful if some resources (like events) should be indexed with lower priorities after a certain date. A pivot task will be scheduled at the specified date.
Per default no repivot will be scheduled.</p>
<p>See <a class="reference internal" href="/id/1281#cookbook-custom-pivots"><span class="std std-ref">Custom pivots</span></a> for adding your own custom pivot columns.</p>
</div>


           </div>

License: 

Attribution: 

Related resources: https://zotonic.com/api/agent/related/1282?language=en


## API access

- [API help](<https://zotonic.com/api-help>)
- [OpenAPI specification](<https://zotonic.com/openapi.json>)
- [This resource as JSON](<https://zotonic.com/api/agent/resource/1282?language=en>)
