a week ago
I am trying to delete an indexed product from the Solr from both the cores listed below using the code.
1) master_backoffice_backoffice_product_flip
2) master_backoffice_backoffice_product_flop
public void deleteProductFromSolr(ProductModel product, List <HttpSolrClient> solrNodes) throws SolrServerException, IOException {
solrNodes.forEach(solrNode -> {
try {
BasicCredentialsProvider credentialsProvider = new BasicCredentialsProvider();
credentialsProvider.setCredentials(AuthScope.ANY, new UsernamePasswordCredentials("solradmin","admin123"));
CloseableHttpClient httpClient = HttpClients.custom()
.setDefaultCredentialsProvider(credentialsProvider)
.build();
HttpSolrClient solrClient = new HttpSolrClient.Builder(solrNode.getBaseURL())
.withHttpClient(httpClient)
.build();
solrClient.deleteById(product.getPk().toString());
deleteById() method throws exception " IOException occurred when talking to server" whenever it attempts to delete the document. Please check the attached log snippet for the reference.
On the contrary, below code works fine to get the solrCores while communicating with Solr.
private List<String> getSolrCores(String endpointUrl) {
//Building Solr server instance
HttpSolrClient solr=new HttpSolrClient.Builder(endpointUrl).build();
solr.setParser(new XMLResponseParser());
//Requesting core list
CoreAdminRequest request = new CoreAdminRequest();
request.setBasicAuthCredentials("solradmin","admin123");
request.setAction(CoreAdminParams.CoreAdminAction.STATUS);
CoreAdminResponse cores=null;
try {
cores = request.process(solr);
} catch (SolrServerException | IOException e) {
LOG.error("Error finding the solr core for the base url: [{}]", solr.getBaseURL(), e);
}
//Listing cores
List<String> coreList = new ArrayList<String>();
cores.getCoreStatus().forEachEntry((k, v) -> {
v.forEach((k1, v1) -> {
if (k1.equals("name")) {
coreList.add(v1.toString());
}
});
});
return coreList;
}
Requesting your help to fix this issue.
User | Count |
---|---|
2 | |
2 | |
2 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.