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 |
In general, Web applications do not display all the search results on a single page, but limit the number of items shown on each page.
Specify the reply start number (ReplyNumber) and the number of items to return per request (RequestCount) of the ShunSearchRequirement object to control the number of items of data to be obtained.
The following diagram shows the process for obtaining search results according to the number of data items.
ShunService service = new ShunService(); service.Connect(); ShunSearchRequirement req = new ShunSearchRequirement(); (1) req.QueryExpression = "/document/base/prefecture == 'Sydney'"; (1) req.ReturnExpression = "/document/base/name, /document/base/price"; (1) req.ReplyNumber = 11; (1) req.RequestCount = 5; (1) ShunResultSet rs = service.Search( req ); (2) Console.WriteLine( "[Number of hits] = {0}", rs.HitCount ); int i = 0; foreach ( ShunRecord record in rs.Records ) { (3) ++i; Console.WriteLine( "[Result] Item No.{0} = {1}", i, record.Data ); (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 = "/document/base/name, /document/base/price" (1) req.ReplyNumber = 11 (1) req.RequestCount = 5 (1) Dim rs As ShunResultSet = service.Search( req ) (2) Console.WriteLine( "[Number of hits] = {0}", rs.HitCount ) Dim i As Integer = 0 For Each record As ShunRecord In rs.Records (3) i += 1 Console.WriteLine( "[Result] Item No.{0} = {1}", i, record.Data ) (3) Next service.Disconnect() |
Create the ShunSearchRequirement object, and then set the following properties as search conditions.
Propoties |
Description |
---|---|
QueryExpression |
Specifies the search expression. This property can not be omitted. |
ReturnExpression |
Specifies the return expression. |
ReplyNumber |
Specifies the reply start number. 1 is specified if it is omitted. |
RequestCount |
Specifies the number of the 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 number of items to return per request, specify the number of data items to display on each page.
For the search, specify and use the ShunSearchRequirement object that has set the search conditions in the Search method.A ShunResultSet object will be created to hold the results of the search.
The number of hits (XML documents that match the search conditions) can be obtained using the HitCount property of the ShunResultSet object.
This value can be used to find such things as the number of pages of the search results.
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. |
Note: The GetDividedData method is an effective way to extract search results in text format.
Contents
Index
![]() ![]() |