parent
fe7cf8b63f
commit
609f6e7516
|
@ -19,8 +19,7 @@ import io.minio.GetObjectArgs;
|
||||||
import io.minio.MinioClient;
|
import io.minio.MinioClient;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.elasticsearch.search.SearchHit;
|
||||||
import org.elasticsearch.action.search.SearchResponse;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
@ -204,14 +203,40 @@ public class DemoController {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@GetMapping("demo222")
|
||||||
|
public Result<?> demo222() {
|
||||||
|
|
||||||
|
|
||||||
|
SearchHit[] hits = productEsMapper.search(new LambdaEsQueryWrapper<ProductDocument>()
|
||||||
|
.eq(ProductDocument::getPrice, 8999)).getHits().getHits();
|
||||||
|
for (SearchHit hit : hits) {
|
||||||
|
|
||||||
|
System.out.println(hit.getSourceAsMap().get("price"));
|
||||||
|
System.out.println(hit.getSourceAsMap().get("name"));
|
||||||
|
System.out.println(hit.getSourceAsMap().get("description"));
|
||||||
|
System.out.println(hit.getSourceAsMap().get("category"));
|
||||||
|
System.out.println(hit.getSourceAsMap().get("stock"));
|
||||||
|
}
|
||||||
|
// ArrayList<Integer> integers = new ArrayList<>();
|
||||||
|
// integers.add(1);
|
||||||
|
// integers.forEach(i -> System.out.println("i = " + i));
|
||||||
|
|
||||||
|
|
||||||
|
// System.out.println(productEsMapper.search(new LambdaEsQueryWrapper<ProductDocument>()
|
||||||
|
// .eq(ProductDocument::getPrice, 8999)).getHits().getHits());
|
||||||
|
|
||||||
|
return Result.success("demo222");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@GetMapping("demo333")
|
@GetMapping("demo333")
|
||||||
public Result<?> demo333() {
|
public Result<?> demo333() {
|
||||||
// 执行ES查询并格式化打印结果
|
// 执行ES查询并格式化打印结果
|
||||||
LambdaEsQueryWrapper<ProductDocument> wrapper = new LambdaEsQueryWrapper<>();
|
LambdaEsQueryWrapper<ProductDocument> wrapper = new LambdaEsQueryWrapper<>();
|
||||||
wrapper.eq(ProductDocument::getPrice, 8999);
|
wrapper.eq(ProductDocument::getPrice, 8999);
|
||||||
|
|
||||||
List<ProductDocument> products = productEsMapper.selectList(wrapper);
|
List<ProductDocument> products = productEsMapper.selectList(wrapper);
|
||||||
|
|
||||||
System.out.println("\n=== ES查询结果 ===");
|
System.out.println("\n=== ES查询结果 ===");
|
||||||
if (products.isEmpty()) {
|
if (products.isEmpty()) {
|
||||||
System.out.println("未找到匹配的文档");
|
System.out.println("未找到匹配的文档");
|
||||||
|
@ -225,7 +250,7 @@ public class DemoController {
|
||||||
System.out.println("------------------------");
|
System.out.println("------------------------");
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
return Result.success("demo222");
|
return Result.success("demo222");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue