Month: December 2013

Searching Different File Formats in Windows Search

To index / search various file formats (e.g. Microsoft Office files, PDF files, Email, etc.), IFilter plugin of the corresponding file format need to be installed.

1. Microsoft Office (Word, PowerPoint & Excel)
Install Microsoft Office 2010 Filter Packs

2. PDF Files
Install PDF IFilter 64

3. Outlook Mail
Install Windows Desktop Search: Add-in for Outlook saved mail (.msg file) indexing

4. Lotus Notes Mail
Install Windows Desktop Search: Add-in for Lotus Notes

5. WordPerfect Files
Install WordPerfect Office IFilter

References

Windows Search SDK

Setup Environment
1. Install Microsoft Windows SDK

2. Install Microsoft Windows Search SDK

How to Add Indexing Location

CSearchManager searchManager = new CSearchManager();
CSearchCatalogManager catalogManager = searchManager.GetCatalog("SystemIndex");
CSearchCrawlScopeManager crawlScopeManager = catalogManager.GetCrawlScopeManager();

crawlScopeManager.AddUserScopeRule(@"file:///D:\My Documents\", 1, 1, 1);
crawlScopeManager.SaveAll();

catalogManager.Reindex();

How to Search Indexed Location

CSearchManager searchManager = new CSearchManager();
CSearchCatalogManager catalogManager = searchManager.GetCatalog("SystemIndex");

CSearchQueryHelper queryHelper = catalogManager.GetQueryHelper();
queryHelper.QueryWhereRestrictions = @"AND scope='file:D:\My Documents\'";

string sql = queryHelper.GenerateSQLFromUserQuery("Hello World");

using (OleDbConnection conneciton = new OleDbConnection(queryHelper.ConnectionString))
{
	using (OleDbCommand command = new OleDbCommand(sql, conneciton))
	{
		conneciton.Open();
		using (OleDbDataReader dataReader = command.ExecuteReader())
		{
			while (dataReader.Read())
			{
				Console.WriteLine(dataReader[0]);
			}
		}
	}
}

References