|
|
@ -45,9 +45,9 @@ import java.util.List; |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public class RecentSearchManager implements AlphaFineSearchProvider { |
|
|
|
public class RecentSearchManager implements AlphaFineSearchProvider { |
|
|
|
private static final int MAX_SIZE = 100; |
|
|
|
private static final int MAX_SIZE = 100; |
|
|
|
|
|
|
|
|
|
|
|
private static final RecentSearchManager INSTANCE = new RecentSearchManager(); |
|
|
|
private static final RecentSearchManager INSTANCE = new RecentSearchManager(); |
|
|
|
|
|
|
|
|
|
|
|
private IndexReader indexReader = null; |
|
|
|
private IndexReader indexReader = null; |
|
|
|
//索引存储路径
|
|
|
|
//索引存储路径
|
|
|
|
private String path = ProductConstants.getEnvHome() + File.separator + "searchIndex"; |
|
|
|
private String path = ProductConstants.getEnvHome() + File.separator + "searchIndex"; |
|
|
@ -58,18 +58,18 @@ public class RecentSearchManager implements AlphaFineSearchProvider { |
|
|
|
private IndexWriterConfig config = new IndexWriterConfig(Version.LUCENE_40, analyzer); |
|
|
|
private IndexWriterConfig config = new IndexWriterConfig(Version.LUCENE_40, analyzer); |
|
|
|
private IndexWriter indexWriter = null; |
|
|
|
private IndexWriter indexWriter = null; |
|
|
|
private SearchResult recentModelList = new SearchResult(); |
|
|
|
private SearchResult recentModelList = new SearchResult(); |
|
|
|
|
|
|
|
|
|
|
|
public static RecentSearchManager getInstance() { |
|
|
|
public static RecentSearchManager getInstance() { |
|
|
|
|
|
|
|
|
|
|
|
return INSTANCE; |
|
|
|
return INSTANCE; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public SearchResult getLessSearchResult(String[] searchText) { |
|
|
|
public SearchResult getLessSearchResult(String[] searchText) { |
|
|
|
|
|
|
|
this.recentModelList = new SearchResult(); |
|
|
|
SearchResult modelList = new SearchResult(); |
|
|
|
SearchResult modelList = new SearchResult(); |
|
|
|
for (String aSearchText : searchText) { |
|
|
|
for (String aSearchText : searchText) { |
|
|
|
recentModelList = getRecentModelList(aSearchText); |
|
|
|
getRecentModelList(aSearchText); |
|
|
|
} |
|
|
|
} |
|
|
|
if (recentModelList != null && recentModelList.size() > 0) { |
|
|
|
if (recentModelList != null && recentModelList.size() > 0) { |
|
|
|
modelList.add(new MoreModel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_AlphaFine_Latest"))); |
|
|
|
modelList.add(new MoreModel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_AlphaFine_Latest"))); |
|
|
@ -86,7 +86,7 @@ public class RecentSearchManager implements AlphaFineSearchProvider { |
|
|
|
public SearchResult getMoreSearchResult(String searchText) { |
|
|
|
public SearchResult getMoreSearchResult(String searchText) { |
|
|
|
return new SearchResult(); |
|
|
|
return new SearchResult(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private synchronized SearchResult getRecentModelList(String searchText) { |
|
|
|
private synchronized SearchResult getRecentModelList(String searchText) { |
|
|
|
return searchBySort(searchText); |
|
|
|
return searchBySort(searchText); |
|
|
|
} |
|
|
|
} |
|
|
@ -161,7 +161,6 @@ public class RecentSearchManager implements AlphaFineSearchProvider { |
|
|
|
* 按序搜索 |
|
|
|
* 按序搜索 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
private synchronized SearchResult searchBySort(String key) { |
|
|
|
private synchronized SearchResult searchBySort(String key) { |
|
|
|
recentModelList = new SearchResult(); |
|
|
|
|
|
|
|
try { |
|
|
|
try { |
|
|
|
|
|
|
|
|
|
|
|
initReader(); |
|
|
|
initReader(); |
|
|
@ -175,7 +174,6 @@ public class RecentSearchManager implements AlphaFineSearchProvider { |
|
|
|
Query query = new TermQuery(term); |
|
|
|
Query query = new TermQuery(term); |
|
|
|
TopFieldDocs docs = searcher.search(query, MAX_SIZE, sortKey); |
|
|
|
TopFieldDocs docs = searcher.search(query, MAX_SIZE, sortKey); |
|
|
|
ScoreDoc[] scores = docs.scoreDocs; |
|
|
|
ScoreDoc[] scores = docs.scoreDocs; |
|
|
|
this.recentModelList = new SearchResult(); |
|
|
|
|
|
|
|
//遍历结果
|
|
|
|
//遍历结果
|
|
|
|
for (ScoreDoc scoreDoc : scores) { |
|
|
|
for (ScoreDoc scoreDoc : scores) { |
|
|
|
Document document = searcher.doc(scoreDoc.doc); |
|
|
|
Document document = searcher.doc(scoreDoc.doc); |
|
|
|