Merge branch 'develop_master' into FOTON

This commit is contained in:
super_liu
2022-05-01 14:19:13 +08:00
2 changed files with 13 additions and 6 deletions
@@ -1221,7 +1221,7 @@ public class SearchCenterServiceImpl implements SearchCenterService {
hiBuilder.field(highlightDate); hiBuilder.field(highlightDate);
hiBuilder.preTags("<span class='highlight-class'>"); hiBuilder.preTags("<span class='highlight-class'>");
hiBuilder.postTags("</span>"); hiBuilder.postTags("</span>");
updateIndex("fulltextserch",99999999,2); updateIndex("fulltextserch",(searchInfoEO.getPage()-1)*searchInfoEO.getPageSize(),searchInfoEO.getPageSize());
searchRequestBuilder = client.prepareSearch("fulltextserch") searchRequestBuilder = client.prepareSearch("fulltextserch")
.setSearchType(SearchType.DFS_QUERY_THEN_FETCH) .setSearchType(SearchType.DFS_QUERY_THEN_FETCH)
.highlighter(hiBuilder) .highlighter(hiBuilder)
@@ -1515,7 +1515,7 @@ public class SearchCenterServiceImpl implements SearchCenterService {
hiBuilder.preTags("<span class='highlight-class'>"); hiBuilder.preTags("<span class='highlight-class'>");
hiBuilder.postTags("</span>"); hiBuilder.postTags("</span>");
updateIndex("fulltextserch",99999999,2); updateIndex("fulltextserch",(searchInfoEO.getPage()-1)*searchInfoEO.getPageSize(),searchInfoEO.getPageSize());
searchRequestBuilder = client.prepareSearch("fulltextserch") searchRequestBuilder = client.prepareSearch("fulltextserch")
.setSearchType(SearchType.DFS_QUERY_THEN_FETCH) .setSearchType(SearchType.DFS_QUERY_THEN_FETCH)
.highlighter(hiBuilder) .highlighter(hiBuilder)
@@ -1586,6 +1586,7 @@ public class SearchCenterServiceImpl implements SearchCenterService {
AcknowledgedResponse indexResponse = client.admin().indices() AcknowledgedResponse indexResponse = client.admin().indices()
.prepareUpdateSettings(indices) .prepareUpdateSettings(indices)
.setSettings(Settings.builder() .setSettings(Settings.builder()
.put("index.max_result_window", records)
.put("highlight.max_analyzed_offset", records) .put("highlight.max_analyzed_offset", records)
.build() .build()
).get(); ).get();
@@ -111,6 +111,7 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation; import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import java.io.BufferedInputStream;
import java.io.File; import java.io.File;
import java.io.FileInputStream; import java.io.FileInputStream;
import java.sql.Clob; import java.sql.Clob;
@@ -2973,22 +2974,26 @@ public class SarStandardsInfoServiceImpl extends ServiceImpl<SarStandardsInfoDao
// 判断文件是docx还是PDF // 判断文件是docx还是PDF
if (null != attFileEO.getFileSuffix() && (attFileEO.getFileSuffix().equals("docx") || attFileEO.getFileSuffix().equals("doc") || attFileEO.getFileSuffix().equals("DOC") || attFileEO.getFileSuffix().equals("DOCX") || attFileEO.getFileSuffix().equals("ppt") || attFileEO.getFileSuffix().equals("pptx"))) { if (null != attFileEO.getFileSuffix() && (attFileEO.getFileSuffix().equals("docx") || attFileEO.getFileSuffix().equals("doc") || attFileEO.getFileSuffix().equals("DOC") || attFileEO.getFileSuffix().equals("DOCX") || attFileEO.getFileSuffix().equals("ppt") || attFileEO.getFileSuffix().equals("pptx"))) {
if (attFileEO.getFileSuffix().equals("doc") || attFileEO.getFileSuffix().equals("docx") || attFileEO.getFileSuffix().equals("DOC") || attFileEO.getFileSuffix().equals("DOCX")) { if (attFileEO.getFileSuffix().equals("doc") || attFileEO.getFileSuffix().equals("docx") || attFileEO.getFileSuffix().equals("DOC") || attFileEO.getFileSuffix().equals("DOCX")) {
FileInputStream fis = new FileInputStream(readFilePath); BufferedInputStream bis = new BufferedInputStream(new FileInputStream(new File(readFilePath)));
if (FileMagic.valueOf(fis) == FileMagic.OOXML) { if (FileMagic.valueOf(bis) == FileMagic.OOXML) {
XWPFDocument doc = new XWPFDocument(fis); XWPFDocument doc = new XWPFDocument(bis);
XWPFWordExtractor extractor = new XWPFWordExtractor(doc); XWPFWordExtractor extractor = new XWPFWordExtractor(doc);
String txt = extractor.getText(); String txt = extractor.getText();
content.append(txt); content.append(txt);
extractor.close();
}else { }else {
WordExtractor wordExtractor = new WordExtractor(fis); WordExtractor wordExtractor = new WordExtractor(bis);
String txt = wordExtractor.getText(); String txt = wordExtractor.getText();
content.append(txt); content.append(txt);
wordExtractor.close();
} }
bis.close();
} else { } else {
OPCPackage opcPackage = XWPFDocument.openPackage(readFilePath); OPCPackage opcPackage = XWPFDocument.openPackage(readFilePath);
XWPFWordExtractor extractor = new XWPFWordExtractor(opcPackage); XWPFWordExtractor extractor = new XWPFWordExtractor(opcPackage);
String txt = extractor.getText(); String txt = extractor.getText();
content.append(txt); content.append(txt);
opcPackage.close();
} }
} else { } else {
PDDocument document = PDDocument.load(new File(readFilePath)); PDDocument document = PDDocument.load(new File(readFilePath));
@@ -3001,6 +3006,7 @@ public class SarStandardsInfoServiceImpl extends ServiceImpl<SarStandardsInfoDao
// String[] lines = pdfFileInText.split("\\r?\\n"); // String[] lines = pdfFileInText.split("\\r?\\n");
content.append(pdfFileInText); content.append(pdfFileInText);
} }
document.close();
} }
} catch (Exception e) { } catch (Exception e) {
logger.error("搜索中心新增数据读取文档内容时失败"); logger.error("搜索中心新增数据读取文档内容时失败");