The es mapping is a new version of elasticSearch, but the es mapping is a new version of elasticSearch, which is a new version of ElasticSearch. I don’t have to use the spring-boot-ElasticSearch library, but I have to refer to its code and use it whenever I can.
First look at the official website:
Spring Data Elasticsearch – Reference Documentation
- Earlier versions of Spring Data Elasticsearch used a Jackson based conversion, X introduced the Meta Model Object Mapping. As of Version 4.0 only the Meta Object Mapping is used, the Jackson based mapper is not available anymore and the MappingElasticsearchConverter is used.
In 3.2 x es in the previous version or with Jackson, 4.0 after using their own implementation MappingElasticsearchConverter. Java
Take a look at the source code and refer to the design of Spring-data:
The repository of ElasticsearchRepository inherits from ElasticsearchRepository and the index does not exist.
@Override
protected boolean doExists(String indexName) {
GetIndexRequest request = new GetIndexRequest(indexName);
return restTemplate.execute(client -> client.indices().exists(request, RequestOptions.DEFAULT));
}
Copy the code
By default, Model first reads whether @mapping (user-defined handwritten Mapping JSON text address) is set, and then does not look for @document to handle the Mapping relationship.
Before processing the mapping, check to see if @dynamicTemplates is used to create the ES Index template and decide whether to reuse it.
Start building the Mapping:
@TRANSIENT or ignored fields will be ignored, and at the end of the build we can get a:
{
"properties": {"date": {"type":"date"
},
"location": {"type":"geo_point"}}}Copy the code
Github Archive: github.com/pkwenda/Blo…