|\| | |-| € [)

[Solr] get list cores from your RequestHandler

In Solr, RequestHandler are called from a specific core.
But, there is many cases where we want to have more information from other cores.

The easist way is to get this information directly from the the request parameter. Indeed, in your handleRequestBody:

  1. @Override
  2. public void handleRequestBody(SolrQueryRequest req, SolrQueryResponse rsp) throws Exception {

Get your current core.

  1. final SolrCore core = req.getCore();

Retrieve CoreContainer using core object.
CoreContainer contain all cores, so, can be used easily to get all cores.

  1. final Collection<SolrCore> cores = core.getCoreDescriptor().getCoreContainer().getCores();

A loop can be used to display our cores.

  1. for (SolrCore solrCore : cores) {
  2.     log.info(solrCore.getName());
  3. }

😉 you can call a get to retrieve a specific core

  1. SolrCore core1 = core.getCoreDescriptor().getCoreContainer().getCore("core1");

Update : Don’t forget to close your core after exploitation with core.close()

Categories: geek, java

Linux command 20/02/2014 » « Récupération des BokBok avec Ruby


  1. Be care of CoreContainer().getCore(“…”) because it will increase core ref’ counts. Do not forgot to core.close()

  2. Thank you for this information

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Copyright © 2019 |\| | |-| € [)

Theme by Anders NorenUp ↑