Browse Source

REPORT-9446

【10.0一轮回归】alphafine搜不出本地常用了
master
XiaXiang 6 years ago
parent
commit
5430083bec
  1. 17
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/RecentSearchManager.java

17
designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/RecentSearchManager.java

@ -63,6 +63,7 @@ public class RecentSearchManager implements AlphaFineSearchProvider {
public synchronized static RecentSearchManager getInstance() { public synchronized static RecentSearchManager getInstance() {
if (recentSearchManager == null) { if (recentSearchManager == null) {
recentSearchManager = new RecentSearchManager(); recentSearchManager = new RecentSearchManager();
recentSearchManager.initWriter();
} }
return recentSearchManager; return recentSearchManager;
} }
@ -95,18 +96,14 @@ public class RecentSearchManager implements AlphaFineSearchProvider {
* 初始化indexWriter * 初始化indexWriter
*/ */
private void initWriter() { private void initWriter() {
if (indexWriter == null) {
try {
directory = FSDirectory.open(new File(path));
} catch (IOException e) {
FineLoggerFactory.getLogger().error("cannot open directory " + path);
}
try { try {
File file = new File(path);
StableUtils.mkdirs(file);
directory = FSDirectory.open(file);
indexWriter = new IndexWriter(directory, config); indexWriter = new IndexWriter(directory, config);
} catch (IOException e) { } catch (IOException e) {
FineLoggerFactory.getLogger().error("not privilege to write to" + path); FineLoggerFactory.getLogger().error("not privilege to write to" + path);
} }
}
} }
@ -116,9 +113,8 @@ public class RecentSearchManager implements AlphaFineSearchProvider {
private void initReader() { private void initReader() {
if (indexReader == null) { if (indexReader == null) {
try { try {
File file = new File(path); indexWriter.close();
StableUtils.mkdirs(file); directory = FSDirectory.open(new File(path));
directory = FSDirectory.open(file);
indexReader = DirectoryReader.open(directory); indexReader = DirectoryReader.open(directory);
} catch (IOException e) { } catch (IOException e) {
FineLoggerFactory.getLogger().error("not privilege to read " + path); FineLoggerFactory.getLogger().error("not privilege to read " + path);
@ -169,6 +165,7 @@ public class RecentSearchManager implements AlphaFineSearchProvider {
private synchronized SearchResult searchBySort(String key) { private synchronized SearchResult searchBySort(String key) {
recentModelList = new SearchResult(); recentModelList = new SearchResult();
try { try {
initReader(); initReader();
IndexSearcher searcher = new IndexSearcher(indexReader); IndexSearcher searcher = new IndexSearcher(indexReader);
//构建排序字段 //构建排序字段

Loading…
Cancel
Save