feat(es):

This commit is contained in:
ovo 2024-12-09 23:01:22 +08:00
parent 93491b2713
commit fe7cf8b63f
1 changed files with 24 additions and 8 deletions

View File

@ -19,6 +19,8 @@ import io.minio.GetObjectArgs;
import io.minio.MinioClient;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.elasticsearch.action.search.SearchResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
@ -202,14 +204,28 @@ public class DemoController {
@GetMapping("demo222")
public Result<?> demo222() {
System.out.println("111111111111"+productEsMapper.search(new LambdaEsQueryWrapper<ProductDocument>()
.eq(ProductDocument::getPrice, 8999)));
System.out.println(productEsMapper.search(new LambdaEsQueryWrapper<ProductDocument>()
.eq(ProductDocument::getPrice, 8999)).getHits().getHits());
@GetMapping("demo333")
public Result<?> demo333() {
// 执行ES查询并格式化打印结果
LambdaEsQueryWrapper<ProductDocument> wrapper = new LambdaEsQueryWrapper<>();
wrapper.eq(ProductDocument::getPrice, 8999);
List<ProductDocument> products = productEsMapper.selectList(wrapper);
System.out.println("\n=== ES查询结果 ===");
if (products.isEmpty()) {
System.out.println("未找到匹配的文档");
} else {
products.forEach(product -> {
System.out.println("\n商品ID: " + product.getId());
System.out.println("商品名称: " + product.getName());
System.out.println("商品价格: " + product.getPrice());
System.out.println("商品分类: " + product.getCategory());
System.out.println("商品描述: " + product.getDescription());
System.out.println("------------------------");
});
}
return Result.success("demo222");
}