有了ElasticSearchTemplate
我可以很容易地从一个简单的实体类中创建索引。假设我想保存 Book.java:
@Document(indexName = "bookshop", type = "book", shards = 2, replicas = 2, refreshInterval = "-1")
public class Book {
@Id
private String id;
@Field(type = FieldType.String, store = true)
private String title;
}
它足以使:
elasticsearchTemplate.createIndex(Book.class);
elasticsearchTemplate.putMapping(Book.class);
elasticsearchTemplate.refresh(Book.class);
这可以通过纯 ES Java API 实现,而无需spring-data-elasticsearch
对字符串(JSON)进行 and 操作吗?