Index beans with HippoSolrClient - BloomReach Experience - Open Source CMS

Index beans with HippoSolrClient

You can very easily inject your own objects to index into Solr with the HippoSolrClient.

Assume you have your pojo/bean MyBean that implements the IdentifiableContentBean's. Then adding it to Solr index is trivial. For example:

MyBean myBean = ....
HippoSolrClient solrClient = HstServices.getComponentManager().
                               getComponent(HippoSolrClient.class.getName(),
                                            "org.hippoecm.hst.solr");
try {
    solrClient.getSolrServer().addBean(myBean);
    UpdateResponse commit =  solrManager.getSolrServer().commit();
} catch (IOException e) {
    // log error
} catch (SolrServerException e) {
    // log error
}

or

Add MyBeans to the Solr index:

List<MyBean> myBeans = ....
HippoSolrClient solrClient = HstServices.getComponentManager().
                               getComponent(HippoSolrClient.class.getName(),
                                            "org.hippoecm.hst.solr");
try {
    solrManager.getSolrServer().addBeans(myBeans);
    UpdateResponse commit =  solrManager.getSolrServer().commit();
} catch (IOException e) {
    // log error
} catch (SolrServerException e) {
    // log error
}
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?