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?

    We rely on cookies

    to optimize our communication and to enhance your customer experience. By clicking on the Accept and Close button, you agree to the collection of cookies. You can also adjust your preferences by clicking on Manage Preferences. For more information please see our Privacy policy.

    Manage cookies
    Accept & close

    Cookies preferences

    Accept & close
    Back