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;
}
By using SolrInputDocument class I am able to insert document which contains multiple nested documents, Even addBeans method (Below SolrJ Code) is also doing the same. So should I have to construct SolrInputDocument object for each of my bean for indexing. Is it the only solution.
Refer below URL for nested document insertion and searching:
Searching for nested Documents in Solr(J)
If you are using Solr6 and getting null pointer exception then refer: SOLRJ-6.0.0: Insertion of a bean object which associate list of bean object is giving null pointer exception
However if you are trying to insert a bean which associates nested bean then it will give you the exception:
clazz.getName() + " cannot have more than one Field with child=true"
It will be by below piece of code of DocumentObjectBinder Class of SolrJ: