Search in sources :

Example 31 with IndexQuery

use of org.springframework.data.elasticsearch.core.query.IndexQuery in project IT-Demo by yanghaiji.

the class EsRestTemplateImpl method insertItemDocBulk.

/**
 * <p>
 * 批量信息
 * </p>
 *
 * @param
 * @return void
 * @version 1.0.0
 * @author hai ji
 * @since 2022/2/9
 */
public void insertItemDocBulk() {
    List<IndexQuery> list = new ArrayList<>();
    list.add(new IndexQueryBuilder().withObject(UserEntity.builder().id(System.currentTimeMillis()).brand("javayh").images("es.png").price(2020.29).title("Java有货").build()).build());
    list.add(new IndexQueryBuilder().withObject(UserEntity.builder().id(System.currentTimeMillis() + 1).brand("javayh").images("es.png").price(2020.29).title("Java有货").build()).build());
    elasticsearchTemplate.bulkIndex(list, IndexCoordinates.of("sys_user"));
}
Also used : IndexQueryBuilder(org.springframework.data.elasticsearch.core.query.IndexQueryBuilder) IndexQuery(org.springframework.data.elasticsearch.core.query.IndexQuery) ArrayList(java.util.ArrayList)

Aggregations

IndexQuery (org.springframework.data.elasticsearch.core.query.IndexQuery)31 Test (org.junit.jupiter.api.Test)12 SpringIntegrationTest (org.springframework.data.elasticsearch.junit.jupiter.SpringIntegrationTest)9 ArrayList (java.util.ArrayList)8 IndexCoordinates (org.springframework.data.elasticsearch.core.mapping.IndexCoordinates)8 DisplayName (org.junit.jupiter.api.DisplayName)4 IndexQueryBuilder (org.springframework.data.elasticsearch.core.query.IndexQueryBuilder)4 NativeSearchQuery (org.springframework.data.elasticsearch.core.query.NativeSearchQuery)4 NativeSearchQueryBuilder (org.springframework.data.elasticsearch.core.query.NativeSearchQueryBuilder)4 BoolQueryBuilder (org.elasticsearch.index.query.BoolQueryBuilder)3 HashMap (java.util.HashMap)2 QueryBuilder (org.elasticsearch.index.query.QueryBuilder)2 BeforeEach (org.junit.jupiter.api.BeforeEach)2 SeqNoPrimaryTerm (org.springframework.data.elasticsearch.core.query.SeqNoPrimaryTerm)2 Commodity (com.example.esdemo.dto.Commodity)1 CommonException (com.huaxing.springboot_elasticsearch.common.utils.CommonException)1 UserEntity (com.javayh.elaticsearh.docment.UserEntity)1 Field (java.lang.reflect.Field)1 SimpleDateFormat (java.text.SimpleDateFormat)1 Collection (java.util.Collection)1