Managing mappings
After creating an index, the next step is to add some mappings to it. We have already seen how to add a mapping via the REST API in Chapter 3, Basic Operations. In this recipe, we will look at how to manage mappings via a native client.
Getting ready
You need an up-and-running Elasticsearch installation, which we described how to get in the Downloading and installing Elasticsearch recipe in Chapter 1, Getting Started.
A Maven tool or an IDE that natively supports it for Java programming, such as Visual Studio Code, Eclipse, or IntelliJ IDEA, must be installed.
The code for this recipe is in the ch13/elasticsearch-java-client
directory and the referred class is MappingOperations
.
How to do it...
In the following steps, we add a mapping to a myindex
index via the native client:
- Import the required classes using the following code:
import co.elastic.clients.elasticsearch.ElasticsearchClient; import java.io.IOException; import java.security.KeyManagementException...