Book Image

Solr Cookbook - Third Edition

By : Rafal Kuc
Book Image

Solr Cookbook - Third Edition

By: Rafal Kuc

Overview of this book

Table of Contents (18 chapters)
Solr Cookbook Third Edition
Credits
About the Author
Acknowledgments
About the Reviewers
www.PacktPub.com
Preface
Index

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.

  1. 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"...