Search in a specific Field instead of default field - BloomReach Experience - Open Source CMS

This article covers a Hippo CMS version 10. There's an updated version available that covers our most recent release.

12-05-2015

Search in a specific Field instead of default field

By default, searches are done against the defaultSearchField configured in the Solr schema.xml

<!-- field for the QueryParser to use when an explicit fieldname is absent -->
<defaultSearchField>text</defaultSearchField>

If you want to search only in a specific field, you can do this through specifying df

Search only in title:

HippoSolrClient solrClient =
      HstServices.getComponentManager().getComponent(
                    HippoSolrClient.class.getName(), "org.hippoecm.hst.solr");
// set the field to search in to title
query = "{!df=title}" + query;
HippoQuery hippoQuery = solrClient.createQuery(query);
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?