Interstage Shunsaku Data Manager Application Development Guide - Microsoft(R) Windows(R) 2000/ Microsoft(R) Windows Server(TM) 2003 - - UNIX -
|
Contents
Index

|
I.1.1 Obtaining the Number of XML Documents that Match Search Conditions
If there is a large amount of data to be searched, a large number of items may match the search conditions. In this case, it is not practical to return all the data items for the user to view. In such cases, it is useful to find out first how many data items match the specified condition.
The example below shows how to use the C++ .NET to find out how many hotels match the date and location specified as the search condition.
Search Conditions
'How many hotels in Sydney have a vacancy on 2006/07/18?'Execute a search using the date (2006/07/18) and the location (Sydney) as search conditions.
An Example of Using the APIs
The following is a sample program using the C++ .NET.
#using <mscorlib.dll>
#using <system.dll>
#using <Fujitsu.Shunsaku.dll>
using namespace System;
using namespace Fujitsu::Shunsaku;
class SampleHitCount {
public:
static void Main( String *args __gc[] ) {
ShunService *service = 0;
try {
// Create ShunService
service = new ShunService();
// Connect Shunsaku by specifying the host name and port number
service->Host = "DirSvr1";
service->Port = 33101;
service->Connect();
// Search expression
String *query = "/document {/base/city == 'Sydney' AND /information/date == '2006/07/18'}";
// Search the number of hits using the search expression
int hitCount = service->GetHitCount( query );
// Display the number of hits
Console::WriteLine( "Number of hits = {0}", __box( hitCount ) );
// Close the connection to Shunsaku
service->Disconnect();
}
catch ( ShunContinuousException *e ) {
// Processing to perform if ShunContinuousException occurs
try {
if( service != 0 && service->State == ShunConnectionState::Open ) {
service->Disconnect();
}
}
catch ( ShunException *ex ) {
Console::WriteLine( "Error message : {0}", ex->Message );
}
Console::WriteLine( "Error message : {0}", e->Message );
}
catch ( ShunConnectionTerminatedException *e ) {
// Processing to perform if ShunConnectionTerminatedException occurs
Console::WriteLine( "Error message : {0}", e->Message );
}
}
};
int main() {
return SampleHitCount::Main( Environment::GetCommandLineArgs() );
} |
Execution Results
All Rights Reserved, Copyright(C) FUJITSU LIMITED 2006