Creating a client in Scala
The first step for 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.
Getting ready
You will need an up-and-running Elasticsearch installation, as we described in the Downloading and installing Elasticsearch recipe in Chapter 2, Downloading and Setup.
A Maven tool or an IDE that supports Scala programming, such as Eclipse (ScalaIDE) or IntelliJ IDEA, with the Scala plugin should be installed globally.
The code for this recipe can be found in the chapter_15/elastic4s_sample
directory and the reference file is ClientSample.scala
.
How to do it...
To create an Elasticsearch client and for create/search a document, we will perform the following steps:
The first step is to add the
elastic4s
library to thebuild.sbt
configuration via:libraryDependencies += "com.sksamuel.elastic4s" %% "elastic4s- core" % "5.0.0"
If you are using Maven,...