use of org.springframework.data.elasticsearch.core.query.IndexQuery in project spring-data-elasticsearch by spring-projects.
the class NestedObjectTests method shouldIndexMultipleLevelNestedObjectWithIncludeInParent.
@Test
public void shouldIndexMultipleLevelNestedObjectWithIncludeInParent() {
// given
List<IndexQuery> indexQueries = createPerson();
// when
operations.bulkIndex(indexQueries, IndexCoordinates.of("test-index-person-multiple-level-nested"));
// then
Map<String, Object> mapping = operations.indexOps(PersonMultipleLevelNested.class).getMapping();
assertThat(mapping).isNotNull();
Map<String, Object> propertyMap = (Map<String, Object>) mapping.get("properties");
assertThat(propertyMap).isNotNull();
Map bestCarsAttributes = (Map) propertyMap.get("bestCars");
assertThat(bestCarsAttributes.get("include_in_parent")).isNotNull();
}
use of org.springframework.data.elasticsearch.core.query.IndexQuery in project HuaXing-learningCenter by 17666555910.
the class BaseServiceImpl method batchInsertOrUpdate.
@Override
public void batchInsertOrUpdate(List<T> entityModelList) {
if (CollectionUtils.isEmpty(entityModelList)) {
throw new CommonException("entityModelList Can't be empty");
}
// 判断索引是否存在 若不存在则创建索引和映射
if (!elasticsearchTemplate.indexExists(getEntityClass())) {
this.createEntityEsIndex();
}
List<IndexQuery> queries = new ArrayList<>();
for (T entityEsModel : entityModelList) {
IndexQuery indexQuery = new IndexQueryBuilder().withId(entityEsModel.getId()).withObject(entityEsModel).build();
queries.add(indexQuery);
}
// 批量插入
this.bulkInsert(queries);
}
use of org.springframework.data.elasticsearch.core.query.IndexQuery in project fh by assecopl.
the class GenericDtoService method reindexPage.
public Slice<ENTITY> reindexPage(Pageable pageable, Class dtoClass, String indexName, String indexType) {
Slice<ENTITY> slice = getJpaRepository().findAll(pageable);
List<DTO> dtoList = mapEntityToDtoForBulkReindex(slice.getContent());
List<IndexQuery> queries = new ArrayList<>();
for (DTO dto : dtoList) {
IndexQuery indexQuery = new IndexQuery();
indexQuery.setId(dto.getId().toString());
indexQuery.setObject(dto);
// if (StringUtils.isNotBlank(indexType))
// indexQuery.setType(getDtoEsIndexType(dtoClass));
queries.add(indexQuery);
}
IndexCoordinates indexCoordinates = elasticsearchTemplate.getIndexCoordinatesFor(listClazz);
elasticsearchTemplate.bulkIndex(queries, indexCoordinates);
queries.clear();
return slice;
}
use of org.springframework.data.elasticsearch.core.query.IndexQuery in project demo by breeze0630.
the class ElasticsearchTemplateTest method testInsert.
@Test
public void testInsert() {
Commodity commodity = new Commodity();
commodity.setSkuId("1501009005");
commodity.setName("葡萄吐司面包(10片装)");
commodity.setCategory("101");
commodity.setPrice(160);
commodity.setBrand("良品铺子");
IndexQuery indexQuery = new IndexQueryBuilder().withObject(commodity).build();
elasticsearchTemplate.index(indexQuery);
}
use of org.springframework.data.elasticsearch.core.query.IndexQuery in project IT-Demo by yanghaiji.
the class EsRestTemplateImpl method index.
public String index() {
UserEntity userEntity = UserEntity.builder().id(System.currentTimeMillis()).brand("javayh").images("es.png").price(2020.29).title("Java有货").build();
IndexQuery indexQuery = new IndexQueryBuilder().withObject(userEntity).build();
String sys_user = elasticsearchTemplate.index(indexQuery, IndexCoordinates.of("sys_user"));
return sys_user;
}
Aggregations