1

HttpSolrServer/CloudSolrServer support the /schema request handler but that isn't supported on the EmbeddedSolrServer and I would like a way to access the same information using SolrJ (and without HTTP requests).

When using EmbeddedSolrServer, the instance is created by passing a CoreContainer to the constructor. Later, the CoreContainer can be queried for all (well, just the one in the case of an embedded server) SolrCores with the getCores() method. From any given SolrCore I can obtain its schema using getSchema().

I now want to do the same thing but with an HttpSolrServer server and a CloudSolrServer. They, however, don't seem to have a way to ask for the list of loaded SolrCores or CoreContainers or anything. I know about the CoreAdmin but that only retrieves the status of each core, with no way to get Java instances of SolrCore.

Is it possible to obtain a list of SolrCores from a HttpSolrServer/CloudSolrServer using SolrJ, and how is it done?

tar
  • 1,538
  • 1
  • 20
  • 33
  • 1
    Why do you need that information? – YoungHobbit Sep 01 '15 at 03:52
  • did you check this http://stackoverflow.com/questions/6668534/how-can-i-get-a-list-of-all-the-cores-in-a-solr-server-using-solrj – Abhijit Bashetti Sep 01 '15 at 05:21
  • I agree with @abhishekbafna give us a bit of background what you want to achieve, probably there is another way. – cheffe Sep 01 '15 at 10:36
  • Question updated. The schema is already published via the `/schema` resource handler, just not for embedded servers which don't support that resource handler. So `/schema` works for some but not all cases, and `getCores()` works for the exact complement of cases. I am looking for something that will work for all three types of SolrServer. – tar Sep 01 '15 at 12:54

1 Answers1

1

Since Solr 5.3 SolrJ has API for Schema Access - see SchemaRequest.

For example, to retrieve collection schema one can use (in Solr 7) :

CloudSolrClient client = ...;
SchemaRequest request = new SchemaRequest();
SchemaResponse response = request.process(client, "collectionName");
SchemaRepresentation schema = response.getSchemaRepresentation();
arghtype
  • 4,376
  • 11
  • 45
  • 60