2
int length3 = CheckBoxList4.Items.Count;
int count = 0;
for (int i = 0; i < length3; i++)
{
BooleanQuery finalQuery1 = new BooleanQuery();
finalQuery1 = (BooleanQuery)Session["Luc_Query"];
var query1 = new QueryParser("Industry", analyzer).Parse(CheckBoxList4.Items[i].Text);
finalQuery1.Add(query1, BooleanClause.Occur.MUST);
hits = searcher.Search(finalQuery1);
count = hits.Length();
CheckBoxList4.Items[i].Text = CheckBoxList4.Items[i].Text +" " +count.ToString() ;
}
我試圖null爲finalQuery1,但它重複了這個query(finalQuery1.Add(query1, BooleanClause.Occur.MUST);)
的增值。我用於null BooleanQuery的方法在下面,但它仍然不起作用。如何清空lucene.net中的BooleanQuery對象?
finalQuery1 = (BooleanQuery)null;
finalQuery1=null;
缺少強制。答案已更新。 –
謝謝@馬拉斯Musielak.works偉大 –