path.append(searching.name());
File f = new File(path.toString());
if(!f.exists())
return null;
IndexSearcher searcher = new IndexSearcher(path.toString());
//���������ؼ���
BooleanQuery comboQuery = new BooleanQuery();
int _query_count = 0;
StringTokenizer st = new StringTokenizer(params.getSearchKey());
while(st.hasMoreElements()){
String q = st.nextToken();
String[] indexFields = searching.getIndexFields();
for(int i=0;i<indexFields.length;i++){
QueryParser qp = new QueryParser(indexFields[i], analyzer);
try{
Query subjectQuery = qp.parse(q);
comboQuery.add(subjectQuery, BooleanClause.Occur.SHOULD);
_query_count ++;
}catch(Exception e){
log.error("Add query parameter failed. key="+q, e);
}
}
}
if(_query_count==0)//û���κιؼ�������
return null;
//�����ĸ�������
MultiFilter multiFilter = null;
HashMap conds = params.getConditions();
if(conds!=null){
Iterator keys = conds.keySet().iterator();
while(keys.hasNext()){
if(multiFilter == null)
multiFilter = new MultiFilter(0);
String key = (String)keys.next();
multiFilter.add(new FieldFilter(key,conds.get(key).toString()));
}
}
/*
* Creates a sort, possibly in reverse,
* by terms in the given field with the type of term values explicitly given.
*/
SortField[] s_fields = new SortField[2];
s_fields[0] = SortField.FIELD_SCORE;
s_fields[1] = new SortField(searching.getKeywordField(), SortField.INT, true);
Sort sort = new Sort(s_fields);
Hits hits = searcher.search(comboQuery, multiFilter, sort);
int numResults = hits.length();
//System.out.println(numResults + " found............................");
int result_count = Math.min(numResults, MAX_RESULT_COUNT);
List results = new ArrayList(result_count);
for(int i=0;i<result_count;i++){