Creating a client in Scala
The first step in working with Elastic4s is to create a connection client to call Elasticsearch. Similar to Java, the connection client is native and can be a node or a transport one.
Similar to Java, the connection client can be both a native one and an HTTP one.
In this recipe, we'll initialize an HTTP client because it can be put behind a proxy/balancer to increase the high availability of your solution. This is a good practice.
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 chapter_14/elastic4s_sample
directory; the referred class is ClientSample.scala
.
How to do it…
To create an Elasticsearch client and to create/search a document...