I'm using Lucene.NET 3.0.3 to make a search for two fields (I have two fields named "Noidung", "Dapa"), I'm using BooleanQuery
in C# to make this, but when I run this code nothing returns as a result, I'm sure that nothing is wrong with the source to search because I tested it. So can someone that uses Lucene.NET 3.0.3 provide some explanation?
IndexReader indexreader = IndexReader.Open(directory, true);
Searcher indexsearch = new IndexSearcher(indexreader);
BooleanQuery bq = new BooleanQuery();
Query q1 = new TermQuery(new Term("Noidung", PhanSoSanh));
Query q2 = new TermQuery(new Term("Dapa", txtText.Text.ToString().Trim()));
bq.Add(q1, Occur.MUST);
bq.Add(q2, Occur.MUST);
TopDocs ketqua = indexsearch.Search(bq, null, 500);
var hits = ketqua.ScoreDocs;
foreach (var hit in hits)
{
// Return result
}
I have 2 field in index ( "Noidung" , "Dapa" ). Now i wanna search in field "Noidung" and then take result to search with "Dapa" . I use booleanQuery but notthing return in result ? help me?