Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I get a list of all the cores in a solr server using SolrJ

Tags:

java

solr

solrj

We are using Solr for our searches, and sharding the data across several cores. We have one core per week of data, so we are dynamically creating and deleting cores each week.

How can I query a solr server for a list of all its cores? The JavaDoc says I can use coreAdminHandler.getCoreContainer().getCoreNames(), but I'm not sure how to build a coreAdminHandler object.

like image 280
benhsu Avatar asked Jul 12 '11 17:07

benhsu


People also ask

What is SolrJ in Solr?

SolrJ is an API that makes it easy for applications written in Java (or any language based on the JVM) to talk to Solr. SolrJ hides a lot of the details of connecting to Solr and allows your application to interact with Solr with simple high-level methods. SolrJ supports most Solr APIs, and is highly configurable.

Where are Solr cores stored?

Any core. properties file in any directory of your Solr installation (or in a directory under where solr_home is defined) will be found by Solr and the defined properties will be used for the core named in the file. In standalone mode, solr. xml must reside in solr_home .

How can I get data from Solr?

You can index this data under the core named sample_Solr using the post command. Following is the Java program to add documents to Apache Solr index. Save this code in a file with named RetrievingData. java.

What is core in Apache Solr?

A Solr Core is a running instance of a Lucene index that contains all the Solr configuration files required to use it. We need to create a Solr Core to perform operations like indexing and analyzing. A Solr application may contain one or multiple cores.


1 Answers

A request to http://localhost:8983/solr/admin/cores?action=STATUS (replace your own host/port of course) will return all cores.

like image 107
Mauricio Scheffer Avatar answered Oct 18 '22 16:10

Mauricio Scheffer