日期:2014-05-17 浏览次数:20439 次
Sort sortTaxis = new Sort(new SortField[] { new SortField("CGUID",SortField.STRING, true) });
IndexSearcher search = new IndexSearcher("F:\\Index");
int _n = search.MaxDoc();//这里可以看到加载是没有问题的,总记录数2000条
BooleanQuery m_BooleanQuery = new BooleanQuery();
//下面是自己加的两个查询条件
if (this.txtAge.Text.Length>0)
{
QueryParser queryParser = new QueryParser("Age", new Lucene.Net.Analysis.KTDictSeg.KTDictSegAnalyzer(true));
Query queryAge = queryParser.Parse(this.txtAge.Text);
m_BooleanQuery.Add(queryAge, BooleanClause.Occur.MUST);//and操作
}
if (this.txtKeyWord.Text.Length>0)
{
string keyWord = GetKeyWordsSplitBySpaceTo(this.txtKeyWord.Text, new Lucene.Net.Analysis.KTDictSeg.KTDictSegTokenizer());
keyWord = StrReplaceSymbol(keyWord);
QueryParser queryParser = new QueryParser("Name", new Lucene.Net.Analysis.KTDictSeg.KTDictSegAnalyzer(true));
Query query = queryParser.Parse(keyWord);
m_BooleanQuery.Add(query, BooleanClause.Occur.MUST);//and操作
}
Hits hits = search.Search(m_BooleanQuery, sortTaxis);//查询并得到结果
int recCount = hits.Length();//查询结果为0
//........
private Hits seacher(string flg, string lib)
{
Hits hits = null;
try
{
BooleanQuery bq = new BooleanQuery();
IndexSearcher search = RCH.Lucene.LuceneIndex.createsearcher("D:\\WebIndex\\Index_Risk\\");
if (flg != "")
{
if (rbBt.Checked)