Explorar o código

增加验证,如果mongo没取到数据,则不进行ES解析噻。

wukai hai 1 ano
pai
achega
0fa5a48692

+ 6 - 4
doc-biz/src/main/java/com/doc/biz/service/impl/ElasticSearchServiceImpl.java

@@ -52,11 +52,13 @@ public class ElasticSearchServiceImpl implements IElasticSearchService {
             String indexName = "docs_" + info.getSpaceId();
             //获取文件
             DocumentVO vo = mongoService.downloadFile(info.getFileId());
-            String content = handler.apply(vo.getData());
-            EsDocInfo esDocInfo = new EsDocInfo(info.getDocId(), content);
+            if (vo != null) {
+                String content = handler.apply(vo.getData());
+                EsDocInfo esDocInfo = new EsDocInfo(info.getDocId(), content);
 
-            esConfig.setIndexName(indexName);
-            esDocInfoService.save(esDocInfo);
+                esConfig.setIndexName(indexName);
+                esDocInfoService.save(esDocInfo);
+            }
         }
     }