|
@@ -37,6 +37,7 @@ import org.elasticsearch.index.query.QueryBuilders;
|
|
|
import org.elasticsearch.search.SearchHit;
|
|
|
import org.elasticsearch.search.SearchHits;
|
|
|
import org.elasticsearch.search.builder.SearchSourceBuilder;
|
|
|
+import org.springframework.util.ObjectUtils;
|
|
|
|
|
|
/**
|
|
|
* 文件处理工具类
|
|
@@ -341,12 +342,17 @@ public class FileUtils {
|
|
|
|
|
|
//builder.query(QueryBuilders.matchQuery("attachment.content", msg).analyzer("ik_smart"));
|
|
|
SearchResponse searchResponse = EsUtil.selectDocument("fileindex", builder);
|
|
|
- SearchHits hits = searchResponse.getHits();
|
|
|
-
|
|
|
- for (SearchHit hit : hits.getHits()) {
|
|
|
- hit.getSourceAsMap().put("msg", "");
|
|
|
- matchRsult.add(JSON.parseObject(JSON.toJSONString(hit.getSourceAsMap()),EsMessage.class));
|
|
|
- // System.out.println(hit.getSourceAsString());
|
|
|
+ log.info("searchResponse:{}",searchResponse);
|
|
|
+ if(!ObjectUtils.isEmpty(searchResponse)){
|
|
|
+ SearchHits hits = searchResponse.getHits();
|
|
|
+
|
|
|
+ for (SearchHit hit : hits.getHits()) {
|
|
|
+ hit.getSourceAsMap().put("msg", "");
|
|
|
+ matchRsult.add(JSON.parseObject(JSON.toJSONString(hit.getSourceAsMap()),EsMessage.class));
|
|
|
+ // System.out.println(hit.getSourceAsString());
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ log.info("查询条件msg:{}, es查询结果为空",msg);
|
|
|
}
|
|
|
System.out.println("over in the main");
|
|
|
|