如何将数据刷新到 Spring 数据弹性搜索

How to flush data to Spring data elastic search

我运行这个测试用例

Envelope envelope = new Envelope();
envelope.setId("1");
Envelope saved = envelopeRepository.save(envelope);
assertThat(saved.getId()).isEqualTo("1");

保存和信封一样object/reference!所以即使索引不正确,测试仍然通过!如何解决这个问题?

org.elasticsearch.client.RestClient - request [HEAD http://localhost:9200/null?ignore_throttled=false&ignore_unavailable=false&expand_wildcards=open%2Cclosed&allow_no_indices=false]

为什么保存的实体应该是一个新对象? Elasticsearch在保存的时候不会return一个文档,所以这里不需要新建对象

Data Elasticsearch Spring 所做的是使用 return 从索引操作中编辑的信息更新此对象:

  • id 如果尚未在对象上设置但由 Elasticsearch 创建
  • version 如果实体有一个版本 属性
  • seq_noprimary_term 如果实体有这样的 属性

如果索引失败,将抛出异常。

你是什么意思

when the index is incorrect

HEAD 请求对此有何作用?