Retrieving information about the index structure
Until Solr 4.2, we had to look at the schema.xml
file to see the full structure of the document. With the release of Solr 4.2, we got the ability to use the so-called Schema API to read the schema of collections that are running inside the cluster or on a node. In this recipe, we will take a look at the possibilities of reading the Solr schema.
How to do it...
The actual schema.xml
file that we will use for reading doesn't really matter, as we will not focus on the actual index structure, but the API and how to get the particular information from Solr.
Note
We assume that we are using a collection named cookbook
.
We will start with retrieving all the fields defined in our
schema.xml
file. To do this, we will run the following query:http://localhost:8983/solr/cookbook/schema/fields
The response to the preceding command will be as follows:
{ "responseHeader":{ "status":0, "QTime":2}, "fields":[{ "name":"_version_", "type"...