Full Text Query |
Scroll |
If indexing and full text query 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-3 teach you how to define and execute an TheFullTextQuery. The optional steps 4-7 illustrate some common ways to process the results of a full-text query.
1 |
Connect to the Thereforeā¢ server (see "Server - Connect and Disconnect" for Details) |
2 |
Declare and initialize a new TheFullTextQuery. |
3 |
Execute the query. |
4 |
Optional. Show full-text query and results |
5 |
Optional. Retrieve all documents and add them to a list. |
6 |
Optional. Show the index data for each document. |
7 |
Optional. Open the first document in the Thereforeā¢ Viewer |
Requirements and Assumptions: If these assumptions do not apply to your system or configuration please replace them with appropriate values when copying the code samples below. Visual Basic Imports Therefore.API '...
' 1. Connect to the TheServer Dim server As New TheServer server.Connect(TheClientType.CustomApplication)
' 2. Define a query looking for the string 'Therefore' in categories 5 and 9 Dim query As New TheFullTextQuery query.Search = "Therefore" query.Categories.Add(5) query.Categories.Add(9)
' 3. Execute the query Dim result As TheFullTextQueryResult = query.Execute(server)
' Optional 4. Show query and results System.Windows.Forms.MessageBox.Show(query.ToString() _ + vbNewLine + vbNewLine + result.ToString())
' Optional 5. Retrieve all the documents and add them to a list Dim docList As New List(Of TheDocument) Dim row As TheFullTextQueryResultRow For Each row In result docList.Add(row.RetrieveDocument(server)) Next
' Optional 6. Show the index data for all documents Dim doc As TheDocument For Each doc In docList System.Windows.Forms.MessageBox.Show(doc.IndexData.ToString()) Next
' Optional 7. Open the first document in the Thereforeā¢ Viewer If docList.Count > 0 Then docList(0).View() End If C# using Therefore.API; //...
// 1. Connect to the TheServer TheServer server = new TheServer(); server.Connect(TheClientType.CustomApplication);
// 2. Define a query looking for "Therefore" in categories 5 and 9 TheFullTextQuery query = new TheFullTextQuery(); query.Search = "Therefore"; query.Categories.Add(5); query.Categories.Add(9);
// 3. Execute the query TheFullTextQueryResult result = query.Execute(server);
// Optional 4. Show query and results System.Windows.Forms.MessageBox.Show(query.ToString() + "\r\n\r\n" + result.ToString());
// Optional 5. Retrieve all the documents and add them to a list List<TheDocument> docList = new List<TheDocument>(); foreach (TheFullTextQueryResultRow row in result) docList.Add(row.RetrieveDocument(server));
// Optional 6. Show the index data for all documents foreach (TheDocument doc in docList) System.Windows.Forms.MessageBox.Show(doc.IndexData.ToString());
// Optional 7. Open the first document in the Thereforeā¢ Viewer if (docList.Count > 0) docList[0].View(); |