We're sorry GroupDocs doesn't work properply without JavaScript enabled.

Free Support Forum - groupdocs.com

Will search API work with sub-directories using .NET?

Does the Groupdocs index files in sub directories?

@nsanoir

You have to specify indexing directory (it could be anywhere). Please have a look at the following articles:

I am talking about the documents directory. I have thousands of documents in sub-directories. If I specify a directory for the documents will the API search subdirectories as well?

1 Like

@nsanoir

Yes, please have a look at this screenshot.png (36.5 KB). The main directory is D:/sample/, we have a document in sub-directory D:/sample/test/ and the API successfully indexes the Presentation file in sub-directory.
Below is the sample code:

            string indexFolder = @"D:\myindex\"; // Specify path to the index folder
            string documentsFolder = @"D:\sample\"; // Specify the path to a folder containing documents to search
            Index index = new Index(indexFolder); // Creating an index in the specified folder
            index.Add(documentsFolder);
            string query = "directory"; // Specify a search query
            SearchResult result = index.Search(query);
            Console.WriteLine("Documents found: " + result.DocumentCount);
            for (int i = 0; i < result.DocumentCount; i++)
            {
                FoundDocument document = result.GetFoundDocument(i);
                Console.WriteLine("\tDocument: " + document.DocumentInfo.FilePath);
            }

Hopefully, it’ll help you meet the use-case.