use of org.springframework.data.elasticsearch.core.document.Document in project spring-data-elasticsearch by spring-projects.
the class DocumentUnitTests method shouldCreateNewDocumentFromMap.
// DATAES-628
@Test
public void shouldCreateNewDocumentFromMap() {
Document document = Document.from(Collections.singletonMap("key", "value"));
assertThat(document).containsEntry("key", "value");
}
use of org.springframework.data.elasticsearch.core.document.Document in project spring-data-elasticsearch by spring-projects.
the class DocumentUnitTests method shouldRenderToString.
// DATAES-628
@Test
public void shouldRenderToString() {
Document document = Document.from(Collections.singletonMap("key", "value"));
document.setId("123");
document.setVersion(42);
assertThat(document).hasToString("MapDocument@123#42 {\"key\":\"value\"}");
}
use of org.springframework.data.elasticsearch.core.document.Document in project IT-Demo by yanghaiji.
the class EsTempWeb method update.
/**
* <p>
* 更新
* </p>
*
* @param
* @return void
* @version 1.0.0
* @author hai ji
* @since 2022/2/9
*/
@PostMapping
public void update() {
Document document = Document.create();
document.put("title", 1214666);
document.put("price", 66.6);
UpdateQuery updateQuery = UpdateQuery.builder("164439571754").withDocument(document).build();
// 单条更新
UpdateResponse response = elasticsearchTemplate.update(updateQuery, IndexCoordinates.of("sys_user"));
System.out.println(response.getResult().name());
// 批量更新
List<UpdateQuery> list = new LinkedList<>();
list.add(updateQuery);
elasticsearchTemplate.bulkUpdate(list, IndexCoordinates.of("sys_user"));
}
Aggregations