lucene.net三种检索形式 备忘

string INDEX_STORE_PATH = Server.MapPath("index"); //INDEX_STORE_PATH 为索引存储目录 string keyword = TextBox2.Text; Hits myhit = null; IndexSearcher mysea = new IndexSearcher(INDEX_STORE_PATH); ////////////--单一字段搜索--////////////////////// //QueryParser q = new QueryParser("title", new StandardAnalyzer()); //Query query = q.Parse(keyword); ///////////--多字段搜索--//////////////////////// //MultiFieldQueryParser q = new MultiFieldQueryParser(new string[] { "title", "indexcontent" }, new StandardAnalyzer()); //Query query = q.Parse(keyword); //////////////-多关键字-//////////////// QueryParser qp1 = new QueryParser("title", new StandardAnalyzer()); Query query1 = qp1.Parse("aaaa"); QueryParser qp2 = new QueryParser("indexcontent", new StandardAnalyzer()); Query query2 = qp2.Parse("web"); BooleanQuery query = new BooleanQuery(); query.Add(query1, BooleanClause.Occur.SHOULD); query.Add(query2, BooleanClause.Occur.SHOULD); ////////////////////////////// myhit = mysea.Search(query); 

你可能感兴趣的:(String,null,存储,query,Path,textbox)