Magnolia 5.6 reached end of life on June 25, 2020. This branch is no longer supported, see End-of-life policy.
This page describes the Solr Search Provider submodule of the Magnolia Solr module. The submodule contains templates allowing you to display search results on a site. It also provides an autocomplete bar with search suggestions functionality and also faceted search components for additional refining of search results.
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+ DAM assets).
Create a search results page using one of the available templates. Which template you use depends on the type of project you have and the modules that are installed.
Module | Template | Configuration |
---|---|---|
mte | mteSolrSearchResult | /modules/solr-search-provider/templates/mteSolrSearchResult |
standard-templating-kit | solrSearchResult | /modules/solr-search-provider/templates/solrSearchResult |
To try it in the demo travel site:
Enter or modify the values in the Search result settings tab of the Page properties dialog:
In the Client field select which client should be used for search. The field displays all clients configured under Configuration > /modules/solr-search-provider/config/solrClientConfigs
.
You can filter results by a URL domain in the Filter url prefix field:
.
The example query title^100 abstract^0.1
set in the Boost query field will boost the rank for the matches in the title
field 1000 times more than the equivalent matches in the abstract
field:
The query will return the following results:
Conversely, if you decide to boost the abstract
field instead of the title
field, you will get the following results for the same search. The snippets returned are now primarily from page titles:
In the Additional filters field you can define filters to narrow the search results, for example filters for positive and negative filtering:
conference
keyword is present:conference
keyword is present:You can use multiple filters. For more information see Common query parameters: filter query parameter.
The autocomplete search bar provides suggestions while typing in the search field. The jQuery UI Autocomplete widget and info.magnolia.search.solrsearchprovider.logic.servlets.SearchServlet
are used for this functionality.
Link to the jQuery JavaScript libraries from the search results page:
<script src="path to jquery.js" type="text/javascript"></script> <script src="path to jquery-ui.js" type="text/javascript"></script>
Add the following small JavaScript snippet into the search results page:
var jq = jQuery.noConflict(); jq(document).ready(function () { jq("#searchbar, #nav-search, #search").autocomplete({ open: function () { jq(this).autocomplete('widget').css('z-index', 999); }, source: function (request, response) { jq.get("${contextPath}/searchservlet/", {search: request.term.toLowerCase(), queryType: "SUGGEST", fields: "collation", fq: "*", client: "default"}, function (data) { response(data); }, "json" ); }, minLength: 2 }); });
For more information about the autocomplete feature see the following AUTO-COMPLETE series of Karel de Witte's DONE BEFORE YOU TRY blog posts:
Please be aware that these posts may refer to old versions of Solr and Magnolia's Solr module. Some examples described in the post may therefore not work with the latest version. However, the examples are still inspirational and worth reading.
Localized search (a page at Magnolia Community Wiki)
Suggestions