use of com.javayh.elaticsearh.docment.UserEntity in project IT-Demo by yanghaiji.
the class EsTempWeb method agg.
@GetMapping("/agg")
public SearchHits<UserEntity> agg() {
// 构建查询条件
NativeSearchQuery nativeSearchQuery = new NativeSearchQueryBuilder().addAggregation(AggregationBuilders.terms("titles").field("title.keyword")).addAggregation(AggregationBuilders.sum("price sum").field("price")).build();
SearchHits<UserEntity> search = elasticsearchTemplate.search(nativeSearchQuery, UserEntity.class);
return search;
}
use of com.javayh.elaticsearh.docment.UserEntity in project IT-Demo by yanghaiji.
the class EsTempWeb method filter.
@GetMapping("/filter")
public SearchHits<UserEntity> filter() {
// 构建查询条件
NativeSearchQuery nativeSearchQuery = new NativeSearchQueryBuilder().addAggregation(AggregationBuilders.filter("titles", QueryBuilders.termQuery("title", 1214666))).build();
SearchHits<UserEntity> search = elasticsearchTemplate.search(nativeSearchQuery, UserEntity.class);
return search;
}
use of com.javayh.elaticsearh.docment.UserEntity in project IT-Demo by yanghaiji.
the class EsRestTemplateImpl method create.
/**
* <p>
* 保存索引
* </p>
*
* @param
* @return void
* @version 1.0.0
* @author hai ji
* @since 2022/2/9
*/
public void create() {
UserEntity userEntity = UserEntity.builder().id(System.currentTimeMillis()).brand("javayh").images("es.png").price(2020.29).title("Java有货").build();
elasticsearchTemplate.save(userEntity);
}
use of com.javayh.elaticsearh.docment.UserEntity in project IT-Demo by yanghaiji.
the class EsRepoWeb method get.
/**
* <p>
* 根据id 查询
* </p>
*
* @param
* @return void
* @version 1.0.0
* @author hai ji
* @since 2022/2/10
*/
@GetMapping
public void get() {
UserEntity entity = esRepo.findById(1212L).orElse(null);
System.out.println(entity);
}
use of com.javayh.elaticsearh.docment.UserEntity 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