Archive

Posts Tagged ‘search’

Use Windows Desktop Search API Inside of Managed Code

April 17th, 2007
Starting from Windows Desktop Search (WDS) 3.0, a new helper API ISearchQueryHelper is added to help simplify the construction of index OLE DB connection string and search queries. The search service is implemented and the API is exposed as COM objects. Fortunately, there is a way for managed code to invoke the WDS too.
Download the Windows Search SDK. After unzip the package, the search interop assembly (Microsoft.Search.Interop.dll) is in the "Managed" folder. Add it to the reference inside of your solution and put “using Microsoft.Search.Interop; ” at the top of your C# code. Now it’s ready to write C# code and make use of WDS API. Some of the unmanaged and managed counterparts of classes are the following:
Unmanaged
Managed
ISearchManager
CSearchManager
ISearchCatalogManager
CSearchCatalogManager
ISearchQueryHelper
CSearchQueryHelper
 
The following sample code constructs a search query using ISearchQueryHelper to display the sender, recipients, and summary of the first 100 emails that contain a particular keyword (“share” in this example).
int maxSumLength = 100;
 
// Setup the catalog and search query helper
CSearchManager srchMngr = new CSearchManager();
CSearchCatalogManager srchCatMngr = srchMngr.GetCatalog("SystemIndex");
CSearchQueryHelper srchQueryHelper = srchCatMngr.GetQueryHelper();
 
// Assemble the query
srchQueryHelper.QuerySelectColumns = "System.Message.FromAddress, System.Message.ToAddress, System.Search.AutoSummary";
srchQueryHelper.QueryWhereRestrictions = "AND CONTAINS(System.Kind, ‘\"email\"’)";
string sqlQuery = srchQueryHelper.GenerateSQLFromUserQuery("share");
 
// Setup the OLE DB connection
OleDbConnection conn = new OleDbConnection(srchQueryHelper.ConnectionString);
conn.Open();
 
// Execute the query
OleDbCommand cmd = new OleDbCommand(sqlQuery, conn);
OleDbDataReader srchResult = cmd.ExecuteReader();
 
// Process the search result and send to output
for (int i = 0; (i < 100) && srchResult.Read(); ++i)
{
                string fromAddr = "";
                string toAddr = "";
                string sumAddr = "";
 
                if (null != srchResult.GetValue(0) && !(srchResult.GetValue(0) is System.DBNull))
                {
                    string[] addrs = (string[])srchResult.GetValue(0);
                    fromAddr = "From: " + System.String.Join(",", addrs);
                }
                if (null != srchResult.GetValue(1) && !(srchResult.GetValue(1) is System.DBNull))
                {
                    string[] addrs = (string[])srchResult.GetValue(1);
                    toAddr = "To: " + System.String.Join(",", addrs);
                }
                if (null != srchResult.GetValue(2) && !(srchResult.GetValue(2) is System.DBNull))
                {
                    sumAddr = (string)srchResult.GetString(2);
                }
 
                textBox1.AppendText("(" + i + ") ");
                textBox1.AppendText(fromAddr + " " + toAddr + " ");
                textBox1.AppendText("Content: " + (sumAddr.Length <= maxSumLength ? sumAddr : sumAddr.Substring(0, maxSumLength)));
                textBox1.AppendText(Environment.NewLine);
}
 
srchResult.Close();
conn.Close();
           

Search Engine , , ,

Possible Google Phone?

March 14th, 2007

More Pictures Of Possible Google Phone?

Wireless platform would be the next battle field of searching. The day of "technology" is past. In those days computers and software were invented to help people do more things faster. Those things is mostly about information processing. Given a bunch of input and the computers will follow the instructions embedded in the software and produce the expected results. When network was invented to connect computers, it was about transmitting information faster on a much wider scope.

Today, with the already advanced computing and world wide web as the infrastructure, almost all computer technologies are about information and people. Finding the right intelligence and talents. Sitting in front of a desktop or looking for a Wi-Fi hot spot for laptop connection is not efficient enough. A more mobile and slim device is more desirable, so that information is right at the tip of people fingers. Integration of wireless devices and Internet services would be really attractive. I’m imaging the future information searching is pervasive. For example, when you are talking with your friend on the phone and trying to set up a time to go lunch together in a new restaurant. The wireless phone will extract keywords and address from your conversation and you could ask the phone to create this appointment by either pressing a button or saying some voice command. After confirming this appointment, map and driving direction is created too. And you could use it as a GPS to guide you to the venue.  With search-enabled wireless phone, you can also ask the phone to find the closest drug store or coffee shop just by talking.  The search-enabled phone could also be your assistant when you are talking with your friends.  When you do not agree with some ideas in your conversation, ask the phone to do a search on the fly and join your conversation by telling you what it found.

Like partnering with computer manufacturers to pre-install search tool bars on the new computers. Wireless is another competition field. Moto Q with Microsoft Windows Mobile is out there. But I think there is still a lot that can be improved to integrate with Internet services. I look forward to seeing what google phone will bring us.

Tech , , , , ,