The searchindex object is used within the searchindex tag, and provides access to the results of a query.

{% searchindex query: 'support', page: params.page, page_size: 10 %}
{% if searchindex.results.size > 0 %}
<p>Found about {{ searchindex.approximate_total_hits }} matches:</p>
<ul>
{% for result in searchindex.results %}
<li>
<h3><a href="{{ result.url | escape }}">{{ result.title | escape }}</a></h3>
<p>{{ result.fragment }}</p>
</li>
{% endfor %}
</ul>
{% else %}
<p>Your query returned no results.</p>
{% endif %}
{% endsearchindex %}

Attributes

approximate_total_hits

Returns an approximate count of total hits matching the index query.

Note that due to the way the search index works in regards to security filtering and other design factors, this number is only an approximation, and may not exactly match the total number of results available to the current user in some situations.

page

Returns the page number of the current query.

page_size

Returns the maximum page size of the current query.

Note that if you want the actual number of results returned for the current page (as this may be less than the specified maximum page size), use results.size.

results

Returns the query result page, as search index result objects.

Search Index Results

entity

The underlying entity object for the result.

fragment

A relevant short text fragment for the result, with terms matching the specified query highlighted using the <em> HTML tag.

Note that certain types of queries do not support highlighted fragments, such as fuzzy queries (~) and wildcard queries (*). This property will be null in those cases.

id

The CRM entity ID of the underlying record for the result, as a string.

e.g. 936DA01F-9ABD-4d9d-80C7-02AF85C822A8

logical_name

The CRM entity logical name of the underlying record for the result.

e.g. adx_webpage

number

The number of the result, across all result pages, starting from 1.

For example, for the first result of the second page of results, with a page size of 10, this value will be 11.

score

The Lucene score of the result, as a floating-point value. Results will be returned ordered by this value.

title

The title of the result.

url

The URL for the result. This will usually – but not necessarily – be an absolute path for the current application, rather than a full URL.

e.g. /articles/article1/