i will use lucene.net first time so couple of confusion arising in mind when see the line of code. i got a sample code for searching word with lucene and few line are not clear to me.here is sample code below.
Question 1
ListBox1.Items.Clear();
var searcher = new Lucene.Net.Search.IndexSearcher(MapPath("~/searchlucene/"));
var oParser = new Lucene.Net.QueryParsers.QueryParser("content", new StandardAnalyzer());
string sHeader = " OR (header:" + TextBox1.Text + ")";
string sType = " OR (type:" + TextBox1.Text + ")";
string sSearchQuery = "(" + TextBox1.Text + sHeader + sType + ")";
var oHitColl = searcher.Search(oParser.Parse(sSearchQuery));
for (int i = 0; i < oHitColl.Length(); i++)
{
Document oDoc = oHitColl.Doc(i);
ListBox1.Items.Add(new ListItem(oDoc.Get("header") + oDoc.Get("type") + oDoc.Get("content")));
}
searcher.Close();
Question 2
this below lines not clear what is going on...!! please discuss the objective of each line below.
string sHeader = " OR (header:" + TextBox1.Text + ")";
string sType = " OR (type:" + TextBox1.Text + ")";
string sSearchQuery = "(" + TextBox1.Text + sHeader + sType + ")";
var oHitColl = searcher.Search(oParser.Parse(sSearchQuery));
for (int i = 0; i < oHitColl.Length(); i++)
{
Document oDoc = oHitColl.Doc(i);
ListBox1.Items.Add(new ListItem(oDoc.Get("header") + oDoc.Get("type") + oDoc.Get("content")));
}
Question 3
what is header:
what is type:
why heade & type concatinated after search keyword like string sSearchQuery = "(" + TextBox1.Text + sHeader + sType + ")";
Question 4
why content is missing in searchquery content what would be the result if i write like
string sHeader = " OR (header:" + TextBox1.Text + ")";
string sType = " OR (type:" + TextBox1.Text + ")";
string sContent = " OR (content:" + TextBox1.Text + ")";
string sSearchQuery = "(" + TextBox1.Text + sHeader + sType + sContent ")";
why header, type & content is reading....what for?? *oDoc.Get("header") + oDoc.Get("type") + oDoc.Get("content")*
why i need to read header,type & content like oDoc.Get("header") + oDoc.Get("type") + oDoc.Get("content") we can read content only....why type & header is also required??