This page describes how to use the
solrfn templating functions to create a search page based on results from Apache Solr.
The functions are provided by the Solr Templating submodule of the Magnolia
Solr module.
The Solr module integrates Apache Solr,
a standalone enterprise-grade search server with a REST-like API, for
indexing and crawling of Magnolia content, especially if you need to
manage assets in high volumes (100,000+ assets).
Creating a search results page
Templating functions allow you to create FreeMarker templates in
a light development fashion, that is directly from the templates, without any Java development.
By default, the Solr Templating submodule does not provide any templates. This is because every website is different and may have different requirements for searches. Likewise, in spite of the fact that Apache Solr is very flexible search engine, a Solr document schema may look very different for each client.
It is not easy to provide a generic template which would satisfy all the needs. However, it is considered a best practise to create a template which would suit the page and fields in your schema, without any additional generic logic.
Using solrfn in templates
The solrfn templating functions provide methods for most of the common parameters used in Solr. For a full set of the methods, please see the solr page.
[#assign results = solrfn.query(queryTerm)
.clientName("my-client-name") [#-- client used for the search --]
.rows(50) [#-- maximum number of results returned to 50 --]
.field("url", "title", "abstract", "uuid") [#-- restrict fields included in response --]
.filterQuery("destinations:europe")) [#-- only documents which have destination Europe --]
.search()?eval]Copy