One of my students in a Dubai Alchemy SDK class asked about creating an extremely simple search client for Alchemy. Out of the box, Alchemy Search can be fairly easy to use, but there are still a lot of buttons that one could press. And if all you want is a simple search to show all the documents across all your repositories it may be a bit too much. So I created what has to be one of the simplest UIs possible. Since I can't seem to post pictures on this blog, I have to describe it...Imagine a window with 3 controls: top left is a textbox. Below that is a listbox and to the right of both is a empty panel.
As you type in the search box at the top left, results start showing up in the list below then you just click on a document and you get a preview in the viewer.
You can continue typing and your search is refined. No need to press enter. So how did I get here? Well, its just a simple Windows form application with a SplitContainer. Whenever the text in the text box changes, it does the search again. One of the benefits of Alchemy is that the search is extremely quick, so this app is amazingly quick.
When I do the search I have to ensure that the text doesn't end with and or or. If it does, then don't pass it to the search because those are keywords we use. Then I clear the textbox and clear the query. The search itself is easy:
auQuery.AddFullTextQuery(tbSearch.Text);
auQuery.SearchGroup(auSGroup);
if (auQuery.Results.Count > 0)
{
foreach (Alchemy.Result aResult in auQuery.Results)
{
foreach (Alchemy.Item aItem in aResult.Items)
{
lbResults.Items.Add(aItem.Title);
}
}
}
This also populates the listbox. Since I wanted to make it as simple as possible, I don't even show database names. Then when I click on an item, I tell the Viewer to ViewItem(). It took all of 20 minutes to write ugly code while exhausted.