I'm new to Lucene. I've an issue while querying the index file (path) while searching for a string in the files (say: doc files). I've looped through all the files using the following code.
string indexFileLocation = txtRootDirectory.Text.Trim();
Lucene.Net.Store.Directory dir = Lucene.Net.Store.FSDirectory.GetDirectory(indexFileLocation,
false);
Lucene.Net.Search.IndexSearcher searcher = new Lucene.Net.Search.IndexSearcher(dir, false);
Lucene.Net.Index.Term searchTerm = new Lucene.Net.Index.Term("content",
txtSearch.Text.Trim());
Lucene.Net.Search.Query query = new Lucene.Net.Search.TermQuery(searchTerm);
Lucene.Net.Search.Hits hits = searcher.Search(query);
for (int i = 0; i < hits.Length(); i++)
{
Lucene.Net.Documents.Document doc = hits.Doc(i);
StringBuilder contentValue = new StringBuilder();
contentValue.Append(doc.Get("content"));
string id = doc.Get("id");
lblSearchResults.Text += id + "<br />";
}
But unfortunately, I've been getting the same search results, the same file name as follows.
I couldn't figure out if I'm doing wrong anywhere in my code. Please help me out.
Hi everyone,
I'm new to Lucene. I've an issue while querying the index file (path) while searching for a string in the files (say: doc files). I've looped through all the files using the following code.
But unfortunately, I've been getting the same search results, the same file name as follows.
I couldn't figure out if I'm doing wrong anywhere in my code. Please help me out.
Thanks in advance.