Template Tags
Searching is currently limited to a single index for either provider. Algolia supports searching multiple indexes out of the box, but Meilisearch does not, and requires additional steps to support multi-index searching. Thus, for the time being, searching is limited to 1 index if using the EE template tag.
The search template tags are intended for simple queries and results display. If you need users to be able to select multiple facets to filter the result set dynamically, like you're used to seeing on ecommerce sites such as Zappos, we highly recommend using a JavaScript based search component.
Due to the complex nature of the search parameters, they are not defined as native EE tag parameters. There will be too many parsing issues. For this reason Dexter looks for a specific search_filters
tag pair and uses the contents of that tag as the search filter.
Searching
For more information on how to use the search filter refer to the Meilisearch docs.
For more information on how to use the search filter refer to the Algolia search docs.
{% set results = craft.dexter.search({
index: 'demo_collections',
filter: [],
perPage: 50,
}) %}
{% if results %}
<ul>
{% for result in results %}
<li>{{ result.title }}</li>
{% endfor %}
</ul>
{% else %}
<p>No results found.</p>
{% endif %}
Using craft.entries to display results
If the craft.dexter.search
tag is not rendering as you expect, perhaps because of how the data is structured in the index, you can use the idsOnly
parameter to set an ids variable to filter the craft.entries
tag with, then you have access to anything and everything related to the entry. This is a perfectly viable approach - let a powerful search engine do the hard work and return a small set of IDs, which you can then use to display the result.
If you are not using the idsOnly
parameter, remember that the variables in the result are the properties you have indexed in Algolia or Meilisearch, so it may not align exactly with what you normally expect to see in a craft.entries
result.
{% set ids = craft.dexter.search({
index: 'demo_collections',
term: 'empire',
filter: [],
perPage: 50,
idsOnly: true,
}) %}
{% set entries = craft.entries.section('collection').uid(ids).all() %}
{% if entries %}
<ul>
{% for result in entries %}
<li>{{ result.title }}</li>
{% endfor %}
</ul>
{% else %}
<p>No results found.</p>
{% endif %}
Last updated
Was this helpful?