How it works
Elasticsearch is both a NoSQL database and a search engine. You give documents to Elasticsearch and it parses the data in the documents and creates search indexes for that data automatically.
During the insertion process, we used the elasticsearch libraries' .index() method and specified an index, named "planets", a document type, planets_info, and the finally the body of the document, which is our planet Python object. The elasticsearch library that object to JSON and sends it off to Elasticsearch for storage and indexing.
The index parameter is used to inform Elasticsearch how to create an index, which it will use for indexing and which we can use to specify a set of documents to search for when we query. When we performed the query, we specified the same index "planets" and executed a query to match all of the documents.