Executing a standard search
Of course, the most common action in Elasticsearch is searching. Elastic4s leverages the query DSL, which brings a type-safe definition for queries to Scala. One of the most common advantages of this functionality is that, as Elasticsearch evolves, in Scala code via elastic4s
, you can have deprecation. Alternatively, your compilation might break, requiring you to update your code.
In this recipe, we will learn how to execute a search, retrieve the results, and convert them into typed domain objects (classes) without the need to write a serializer/deserializer for our data.
Getting ready
You need an up-and-running Elasticsearch installation, as described in the Downloading and installing Elasticsearch recipe of Chapter 1, Getting Started.
Additionally, an IDE that supports Scala programming, such as IntelliJ IDEA, with the Scala plugin should be installed globally.
The code for this recipe can be found in the ch14/elastic4s_sample
file; the...