Free Support Forum - groupdocs.com

Simple search not returning any docs .net

I am performing a simple search and the code is not returning any documents. Can you tell me what is wrong?

1 Like

@nsanoir,

Can you please share the sample code or application that you are using? Also specify the API version (e.g. 19.5, 19.10) that you integrated in the application. We’ll surely then help you out.

Version 19.10
strFind = WISInput.Text;
string query = strFind;
Index index = new Index(indexFolder);
IndexingOptions optionsIndex = new IndexingOptions();
optionsIndex.IsAsync = true;
index.Add(dataDir, optionsIndex);
SearchResult result = index.Search(query);

lblMessage.Text = "Matches: " + result.DocumentCount;
for (int i = 0; i < result.DocumentCount; i++)
{
FoundDocument document = result.GetFoundDocument(i);
changedFiles.Add(document.DocumentInfo.FilePath);
}

Session.Add(“ChangeFilesList”, changedFiles);
if ((changedFiles != null) && (!changedFiles.Any()))
{
ClearBtn.Visible = false;

}
else
{
ClearBtn.Visible = true;

}
WISInput.Text = string.Empty;
WISInput.Visible = false;

@nsanoir,

We are not able to reproduce this issue using code below (that’s the most simplified code tested in a console application):

string indexFolder = "index path";
string documentsFolder = "documents path";
// Creating an index in the specified folder
Index index = new Index(indexFolder);
// Indexing documents from the specified folder
IndexingOptions optionsIndex = new IndexingOptions();
optionsIndex.IsAsync = true;
index.Add(documentsFolder);
// Search with text query
SearchResult result = index.Search("LOREM");
// Printing the result
Console.WriteLine("Documents found: " + result.DocumentCount);
Console.WriteLine("Total occurrences found: " + result.OccurrenceCount);
for (int i = 0; i < result.DocumentCount; i++)
{
    FoundDocument document = result.GetFoundDocument(i);
    Console.WriteLine("\tDocument: " + document.DocumentInfo.FilePath);
    Console.WriteLine("\tOccurrences: " + document.OccurrenceCount);
} 

Can you please share your project (along-with index and documents path)? We will investigate that. Please don’t share license file in the project.