使用 SolrJ 从 HttpSolrServer 和 CloudSolrServer 检索架构信息

Retrieve schema info from HttpSolrServer and CloudSolrServer with SolrJ

HttpSolrServer/CloudSolrServer support the /schema request handler but that isn't supported on the EmbeddedSolrServer 并且我想要一种使用 SolrJ(无需 HTTP 请求)访问相同信息的方法。

使用 EmbeddedSolrServer 时,通过使用 getCores() 方法传递 CoreContainer to the constructor. Later, the CoreContainer can be queried for all (well, just the one in the case of an embedded server) SolrCores 创建实例。从任何给定的 SolrCore,我都可以使用 getSchema().

获取其模式

我现在想做同样的事情,但使用 HttpSolrServer 服务器和 CloudSolrServer。然而,他们似乎没有办法请求加载的 SolrCores 或 CoreContainers 或任何东西的列表。我知道 CoreAdmin 但它只检索每个核心的状态,无法获取 SolrCore.

的 Java 个实例

是否可以使用 SolrJ 从 HttpSolrServer/CloudSolrServer 获取 SolrCore 列表,如何实现?

自从 Solr 5.3 SolrJ 具有 API 模式访问 - 请参阅 SchemaRequest

例如,要检索集合模式,可以使用(在 Solr 7 中):

CloudSolrClient client = ...;
SchemaRequest request = new SchemaRequest();
SchemaResponse response = request.process(client, "collectionName");
SchemaRepresentation schema = response.getSchemaRepresentation();