Interstage Shunsaku Data Manager Application Development Guide - Microsoft(R) Windows(R) 2000/ Microsoft(R) Windows Server(TM) 2003 - - UNIX - |
Contents
Index
![]() ![]() |
Part 2 Developing Applications by APIs | > Chapter 10 Developing .NET Applications | > 10.3 How to Use .NET APIs | > 10.3.2 Data Searches |
Sometimes it is useful to be able to aggregate the results of a search, using the values of particular elements.
Use the SortExpression property of the ShunSearchRequirement object to aggregate the content of the data. By specifying an aggregation function in the return expression used as a property of the ShunSearchRequirement object, the results of the search will be aggregated before they are returned. The aggregation process can be used to calculate totals, averages, maximums, minimums, and the number of items.
The following diagram shows the process for aggregating the content of data that matches conditions.
ShunService service = new ShunService(); service.Connect(); ShunSearchRequirement req = new ShunSearchRequirement(); (1) req.QueryExpression = "/document/base/prefecture == 'Sydney'"; (1) req.ReturnExpression = "max(/document/base/price/text())"; (1) req.SortExpression = " /document/base/prefecture/text()"; (1) ShunResultSet rs = service.Search( req ); (2) foreach ( ShunRecord record in rs.Records ) { (3) String[][] data = record.GetDividedData(); (3) Console.WriteLine( "[Result] {0}", data[0][0] ); (3) } service.Disconnect(); |
Dim service As New ShunService() service.Connect() Dim req As New ShunSearchRequirement() (1) req.QueryExpression = "/document/base/prefecture == 'Sydney'" (1) req.ReturnExpression = "max(/document/base/price/text())" (1) req.SortExpression = " /document/base/prefecture/text()" (1) Dim rs As ShunResultSet = service.Search( req ) (2) For Each record As ShunRecord In rs.Records (3) Dim data()() As String = record.GetDividedData() (3) Console.WriteLine( "[Result] {0}", data(0)(0) ) (3) Next service.Disconnect() |
Create the ShunSearchRequirement object and set the following properties as the search conditions. For the aggregation, the aggregation function specifications at the return expression have to be set and the group key has to be specified in the sort expression.
Refer to B.4 Return Expressions for more information on return expressions and aggregation function specifications. Refer to B.5 Sort Expressions for more information on sort expressions.
Property |
Description |
---|---|
QueryExpression |
Specifies the search expression. This property cannot be omitted. |
ReturnExpression |
Specifies the return expression. |
SortExpression |
Specifies the sort expression. This property can be omitted if the sort process is not used. |
ReplyNumber |
Specifies the reply start number. 1 is specified if it is omitted. |
RequestCount |
Specifies the number of items to return per request. If it is omitted, the number of search results that can be returned will be the same as specifying at the AnsMax in the conductor environment file or the director environment file. |
Refer to Appendix B Format of Search, Return and Sort Expressions for more information on search expressions and return expressions.
For the search, specify and use the ShunSearchRequirement object that the search conditions have been set by the Search method. A ShunResultSet object will be created to hold the results of the search.
Extract one record of ShunRecord object from the ShunResultSet object. Then extract the XML documents from the ShunRecord object.
The following properties or methods are used to extract XML documents according to the purpose of the extraction. Refer to the table below for the properties and methods that can be used to extract XML documents.
Property or method |
Function |
---|---|
Data property |
Extracts XML documents as String objects. |
GetDividedData method |
Extracts XML documents as a two-dimensional array of String objects. |
GetStream method |
Extracts XML documents as Stream objects. |
Contents
Index
![]() ![]() |