cancel
Showing results for 
Search instead for 
Did you mean: 

IOException occurred when talking to server at http://localhost:8983/solr/master_backoffice_backoffi

kuldeepakpandey
Discoverer
0 Kudos

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.

Screenshot 2024-05-14 032340.png

 

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.

Accepted Solutions (0)

Answers (0)