Switch between AND and OR operator - BloomReach Experience - Open Source CMS
07-07-2017

Switch between AND and OR operator

By default, the operator for searches is OR. Thus searching for 'hippo cms' returns results for documents containing 'hippo' or 'cms' or both terms. The default can be changed in your Solr schema.xml

<!-- SolrQueryParser configuration: defaultOperator="AND|OR" -->
<solrQueryParser defaultOperator="OR"/>

If you want to switch query time to AND operator, you can do this through:

Switch default operator:

HippoSolrClient solrClient =
      HstServices.getComponentManager().getComponent(
                    HippoSolrClient.class.getName(), "org.hippoecm.hst.solr");
// set the q operator to AND
query = "{!q.op=AND}" + 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?