UUUU when you enter on code, they don't like it, "punch lazy bitches".
DART -> ta galopando.
package org.nanotek.lucene.index.search.local;
import java.util.ArrayList;
import java.util.List;
import org.apache.lucene.index.Term;
import org.apache.lucene.search.CollectionStatistics;
import org.apache.lucene.search.IndexSearcher;
import org.nanotek.cms.domain.lucene.FieldStat;
import org.nanotek.cms.domain.lucene.Index;
import org.nanotek.cms.domain.lucene.IndexStats;
import org.nanotek.cms.domain.lucene.TermStats;
import org.nanotek.dao.DAO;
import org.nanotek.lucene.index.search.IndexSearcherProvider;
import org.nanotek.lucene.index.search.Provider;
import org.nanotek.lucene.index.search.SearchService;
import org.nanotek.lucene.query.QueryContext;
import org.nanotek.lucene.query.QueryResult;
public class LocalIndexSearchService implements SearchService {
/** mpve the PAGE SIZE for a mutable integer "in future"...*/
private static final Integer PAGE_SIZE = 300;
private LocalProvider resultsProvider;
private IndexSearcherProvider searchProvider;
private DAO<Index> indexDAO;
public LocalIndexSearchService(){}
public List<Index> getIndexList()
{
return getIndexList (0);
}
private List<Index> getIndexList(int i) {
return indexDAO.listRecords(i, PAGE_SIZE);
}
public QueryResult searchIndex(QueryContext queryContext) throws Exception
{
return resultsProvider.search(queryContext);
}
public QueryResult searchIndex(String searchPhrase) throws Exception
{
return resultsProvider.search(searchPhrase);
}
public QueryResult searchIndex(Index index , String searchPhrase) throws Exception
{
return resultsProvider.search(index, searchPhrase);
}
public List<TermStats> getTermStats (Index index, String... terms) throws Exception
{
List<Term> termList = new ArrayList<>();
for (String term : terms)
{
Term luceneTerm =new Term("TextData" , term);
termList.add(luceneTerm);
}
List<TermStats> termStats = searchProvider.getTermStats (index, termList);
return termStats;
}
public IndexStats getIndexStats (Index index) throws Exception
{
IndexStats indexStats = new IndexStats();
IndexSearcher indexSearcher = searchProvider.getIndexSearcher(index);
CollectionStatistics stats = indexSearcher.collectionStatistics("TextData");
indexStats.setSumDocFreq(stats.sumDocFreq());
indexStats.setStatsFieldCount(stats.docCount());
indexStats.setSumTotalTermFreq(stats.sumTotalTermFreq());
return indexStats;
}
public FieldStat getFieldStat (Index index , String field) throws Exception
{
FieldStat stat = searchProvider.getFieldStat(index, field);
return stat;
}
public Provider getResultsProvider() {
return resultsProvider;
}
public void setResultsProvider(LocalProvider resultsProvider) {
this.resultsProvider = resultsProvider;
}
public IndexSearcherProvider getSearchProvider() {
return searchProvider;
}
public void setSearchProvider(IndexSearcherProvider searchProvider) {
this.searchProvider = searchProvider;
}
public DAO<Index> getIndexDAO() {
return indexDAO;
}
public void setIndexDAO(DAO<Index> indexDAO) {
this.indexDAO = indexDAO;
}
public QueryResult search(String searchPhrase) throws Exception {
assert (resultsProvider !=null);
return resultsProvider.search(searchPhrase);
}
public QueryResult search(Index index, String searchPhrase)
throws Exception {
assert (resultsProvider !=null);
return resultsProvider.search(index, searchPhrase);
}
public QueryResult search(QueryContext queryContext) throws Exception {
assert (resultsProvider !=null);
return resultsProvider.search(queryContext);
}
}