SolrQuery - Bloomreach Experience - Headless Digital Experience Platform


Once you have bootstrapped a HippoQuery through the HippoSolrClient, you have access to the SolrQuery and its entire API, also see If you are familiar with Solrj, you'll be able to use whatever you were used to. If you are not familiar with it, you should easily find your way with the solrj documentation, see

Getting the SolrQuery


HippoSolrClient solrClient = HstServices.getComponentManager().getComponent(
                     HippoSolrClient.class.getName(), "org.hippoecm.hst.solr");
HippoQueryParser parser = solrClient.getQueryParser();
HippoQuery hippoQuery = solrClient.createQuery(parser.escape(query));
SolrQuery solrQuery = hippoQuery.getSolrQuery();

A simple example: Add sorting on date

SolrQuery solrQuery = hippoQuery.getSolrQuery();
solrQuery.addSortField("date", SolrQuery.ORDER.desc);

A simple example: Add highlighting for title and summary in the search results

SolrQuery solrQuery = hippoQuery.getSolrQuery();
solrQuery.setHighlightSimplePre("<b style=\"color:blue\">");

A simple example: Add highlighting in all fields


A simple example: Add spellcheck / did you mean

SolrQuery solrQuery = hippoQuery.getSolrQuery();
solrQuery.add("spellcheck", "true");
solrQuery.add("spellcheck.q", query);
solrQuery.add("spellcheck.extendedResults", "true");
solrQuery.add("spellcheck.collateExtendedResults", "true");
Did you find this page helpful?
How could this documentation serve you better?
On this page
    Did you find this page helpful?
    How could this documentation serve you better?