Chapter 14: Scala Integration
Scala is becoming one of the most widely used languages in big data scenarios. This language provides a lot of facilities for managing data, such as immutability and functional programming.
In Scala, you can simply use the libraries that we saw in the previous chapter for Java. However, they are not scalastic, as they don't provide type safety (because many of these libraries take JSON as a string), and it is easy to use asynchronous programming.
In this chapter, we will look at how we can use elastic4s
, a mature library, to use Elasticsearch in Scala. Its main features are as follows:
- It has type-safe, concise DSL.
- It integrates with standard Scala futures.
- It uses the Scala collections library over the Java collections.
- It returns an option where the Java methods would return
null
. - It uses Scala durations instead of strings/longs for time values.
- It uses type class for marshaling and unmarshaling classes to/from...