In Spark, you can read data from a lot of sources but, in general, with NoSQL datastores such as HBase, Accumulo, and Cassandra, you have a limited query subset, and you often need to scan all the data to read only the required data. Using Elasticsearch, you can retrieve a subset of documents that matches your Elasticsearch query.
Reading data with Apache Spark
Getting ready
You need an up and running Elasticsearch installation, as we described in the Downloading and installing Elasticsearch recipe in Chapter 1, Getting Started.
You also need a working installation of Apache Spark and the data that we indexed in the previous example.