A Full Text Search Query |
Scroll |
If indexing is enabled on your system, you can launch a full text query looking for a specified string in the text body of all documents in a FullTextQuery-enabled Thereforeā¢ category.
Steps 1-5 teach you how to define and execute a full text query. The optional step 6 illustrates some common ways to process the results of a full-text query.
1 |
Create a channel factory to the web service endpoint. |
2 |
Create a channel to the web service endpoint. |
3 |
Define a query looking for "Therefore" in categories |
4 |
Execute the query |
5 |
Close the channel and channel factory. |
6 |
Process a response. |
// 1. Create a channel factory to the web service endpoint
...
ChannelFactory<IThereforeService> channelFactory = new ChannelFactory<IThereforeService>(binding, endpoint);
// 2. Create a channel to the web service endpoint
IThereforeService service = channelFactory.CreateChannel();
// 3. Define a query looking for "Therefore" in categories
ExecuteFullTextQueryParams parameters = new ExecuteFullTextQueryParams();
parameters.FullTextQuery = new WSFullTextQuery { Categories = new CategoryList() };
parameters.FullTextQuery.Search = "Therefore";
parameters.FullTextQuery.Categories.Add(CategoryIds.FilesCategory);
//query.Categories.Add(x);//add more categories here
// 4. Execute the query
ExecuteFullTextQueryResponse response = service.ExecuteFullTextQuery(parameters);
// 5. Close the channel and channel factory.
((IClientChannel)service).Close();
channelFactory.Close();
// 6. Process response.
string info = "Found documents: " + response.Results.Count + Environment.NewLine;
foreach (WSFullTextQueryResultRow row in response.Results)
info += String.Format("Ctgry: {0}, Doc: {1}, Rank: {2}, Title: {3}{4}", row.CategoryNo, row.DocNo, row.Rank, row.Title, Environment.NewLine);
MessageBox.Show(info);