Result sets

The result set object is a container for records returned from a target.


     Z3950_resultset Z3950_connection_search(Z3950_connection,
                                             Z3950_query q);

     Z3950_resultset Z3950_connection_search_pqf(Z3950_connection c,
                                                 const char *q);

     void Z3950_resultset_destroy(Z3950_resultset r);
   

Function Z3950_connection_search creates a result set given a connection and query. Destroy a result set by calling Z3950_resultset_destroy. Simple clients may using PQF only may use function Z3950_connection_search_pqf in which case creating query objects is not necessary.


     const char *Z3950_resultset_option (Z3950_resultset r,
                                         const char *key,
                                         const char *val);

     int Z3950_resultset_size (Z3950_resultset r);

     void *Z3950_resultset_get (Z3950_resultset s, size_t pos,
                                const char *type, size_t *len);
   

Function Z3950_resultset_options sets or modifies an option for a result set similar to Z3950_connection_option.

The number of hits also called result-count is returned by function Z3950_resultset_size.

Function Z3950_resultset_get is similar to Z3950_record_get but instead of operating on a record object, it operates on a record on a given offset within a result set.

Table 3-2. ZOOM Result set Options

OptionDescriptionDefault
piggybackTrue (1) if piggyback should be used in searches; false (0) if not. 1
startOffset of first record to be retrieved from target. First record has offset 0 unlike the protocol specifications where first record has position 1. 0
countNumber of records to be retrieved. 0
elementSetNameElement-Set name of records. Most targets should honor element set name B and F for brief and full respectively. none
preferredRecordSyntaxPreferred Syntax, such as USMARC, SUTRS, etc. none
smallSetUpperBoundIf hits is less than or equal to this value, then target will return all records using small element set name 0
largeSetLowerBoundIf hits is greator than this value, the target will return no records. 1
mediumSetPresentNumberThis value represents the number of records to be returned as part of a search when when hits is less than or equal to large set lower bound and if hits is greator than small set upper bound. 0
smallSetElementSetName The element set name to be used for small result sets. none
mediumSetElementSetName The element set name to be for medium-sized result sets. none
databaseNameOne or more database names separated by character plus (+). Default

Protocol behavior

The creation of a result set involves at least a SearchRequest - SearchResponse protocol handshake. Following that, if a sort critieria was specified as part of the query, a sortRequest - SortResponse handshake takes place. Note that it is necessary to perform sorting before any retrieval takes place, so no records will be returned from the target as part of the SearchResponse because these would be unsorted. Hence, piggyback is disabled when sort critieria is set. Following Search - and a Possible sort, Retrieval takes place - as one or more Present Requests - Present Response being transferred.

The API allows for two different modes for retrieval. A high level mode which is somewhat more powerful and a low level one. The low level is "enabled" when the settings smallSetUpperBound, mediumSetPresentNumber and largeSetLowerBound are set. The low level mode thus allows you to precisely set how records are returned as part of a search response as offered by the Z39.50 protocol. Since the client may be retrieving records as part of the search response, this mode doesn't work well if sorting is used.

The high-level mode allows you to fetch a range of records from the result set with a given start offset. When you use this mode the client will automatically use piggyback if that is possible with the target and perform one or more present requests as needed. Even if the target returns fewer records as part of a present response because of a record size limit, etc. the client will repeat sending present requests. As an example, if option start is 0 (default) and count is 4, and piggyback is 1 (default) and no sorting critieria is specified, then the client will attempt to retrieve the 4 records as part the search response (using piggyback). On the other hand, if either start is positive or if a sorting criteria is set, or if piggyback is 0, then the client will not perform piggyback but send Present Requests instead.

If either of the options mediumSetElementSetName and smallSetElementSetName are unset, the value of option elementSetName is used for piggyback searches. This means that for the high-level mode you only have to specify one elementSetName option rather than three.