Search code examples
javasolrjsolr6

How to insert Bean object which has many child Bean in SolrJ


I have a Bean Class Activity which associates List of Profiles and a User Bean. Now If I am trying to insert this Activity bean in Solr by SOLRJ, it is giving me null pointer exception. The Exception is causing by below piece of code:

public <T> boolean insert (T bean) {
    try {
        UpdateResponse response = solrClient.addBean(bean);
        System.out.println("insert bean ElapsedTime: " + response.getElapsedTime());
        solrClient.commit();
        return true;
    } catch (IOException | SolrServerException e) {
        e.printStackTrace();
    }
    return false;
}

Solution

  • Refer below URL for nested document insertion and searching:

    Searching for nested Documents in Solr(J)