我正在使用弹性 6.3.2 中的 IndexRequest。现在我更改为 7.6.2 版本。如何使用 CreateIndexRequest 执行以下相同的步骤?
Elastic rest 高级客户端 6.3.2 代码:
public Object createIndex(Object document, String id) throws IOException {
Map documentMapper = objectMapper.convertValue(document, Map.class);
IndexRequest indexRequest = new IndexRequest(this.getIndexName(),
type, id).source(documentMapper, XContentType.JSON);
IndexResponse indexResponse = client.index(indexRequest);
return null;
}
切换到 7.6.2 后,我无法在 CreateIndexRequest 中创建类型、id 和源。