MarkLogic Connect
MarkLogic Connect Client API Collection
Public Types | Public Member Functions | Friends | List of all members
mlclient::SearchResultSet Class Reference

A self-advancing result set class. More...

#include <SearchResultSet.hpp>

Public Types

typedef SearchResultSetIterator const_iterator
 

Public Member Functions

MLCLIENT_API SearchResultSet (IConnection *conn, SearchDescription *desc)
 Creates a self-advancing result set given the specified search description. More...
 
virtual MLCLIENT_API ~SearchResultSet ()=default
 Destroys a SearchResultSet and all of its owned resources.
 
MLCLIENT_API SearchResultSetIteratorbegin () const
 Returns the iterator for this result set. More...
 
MLCLIENT_API SearchResultSetIteratorend () const
 Returns a reference to the end of the iterator for this result set. More...
 
MLCLIENT_API bool fetch ()
 Uses the provided Connection and SearchDescription to perform a request, and initial this object and the list of results. More...
 
MLCLIENT_API std::exception * getFetchException ()
 Returns the exception, if any, encountered by fetch(). nullptr is returned if no exception raised. More...
 
MLCLIENT_API const long getStart ()
 Returns the sequence number of the first search result. More...
 
MLCLIENT_API const long getTotal ()
 Returns the total count of all search results, across all pages. More...
 
MLCLIENT_API const long getPageLength ()
 Returns the number of results returned on each page. More...
 
MLCLIENT_API const std::string & getSnippetFormat () const
 Returns the snippet format. Could be raw, none, or snippet. More...
 
MLCLIENT_API const std::string & getQueryResolutionTime () const
 Returns the query resolution time for the last page requested, if available. More...
 
MLCLIENT_API const std::string & getSnippetResolutionTime () const
 Returns the snippet resolution time for the last page requested, if available. More...
 
MLCLIENT_API const std::string & getTotalTime () const
 Returns the total time taken for the last page requested, if available. More...
 
MLCLIENT_API const long getPageCount () const
 Utility function to return the total number of pages in the result set. More...
 
MLCLIENT_API void setMaxResults (long maxResults)
 Sets the maximum number of results to return. Useful if the maximum is larger than the page size. More...
 

Friends

class SearchResultSetIterator
 

Detailed Description

A self-advancing result set class.

Sometimes it is useful to advance beyond 1 page of search results in MarkLogic. This class allows this to happen whilst carrying out any additional page requests to the underlying Connection when needed.

Member Typedef Documentation

A public typedef for the iterator. This prevents recoding if we change the implementation in future.

Constructor & Destructor Documentation

MLCLIENT_API mlclient::SearchResultSet::SearchResultSet ( IConnection conn,
SearchDescription desc 
)

Creates a self-advancing result set given the specified search description.

Parameters
connThe Connection instance pointer
descThe Search Description to use for requests - will be owned by this class

Member Function Documentation

MLCLIENT_API SearchResultSetIterator* mlclient::SearchResultSet::begin ( ) const

Returns the iterator for this result set.

Returns
The iterator for this result set
MLCLIENT_API SearchResultSetIterator* mlclient::SearchResultSet::end ( ) const

Returns a reference to the end of the iterator for this result set.

Returns
A reference to the end of the iterator for this result set
MLCLIENT_API bool mlclient::SearchResultSet::fetch ( )

Uses the provided Connection and SearchDescription to perform a request, and initial this object and the list of results.

Note
You can call the functions begin() and end() immediately after fetch() returns (fetch() uses synchronous request functions in Connection)
Returns
true if no errors were raised, false otherwise
MLCLIENT_API std::exception* mlclient::SearchResultSet::getFetchException ( )

Returns the exception, if any, encountered by fetch(). nullptr is returned if no exception raised.

Returns
The exception instance pointer
MLCLIENT_API const long mlclient::SearchResultSet::getPageCount ( ) const

Utility function to return the total number of pages in the result set.

Returns
The total number of pages in the result set
MLCLIENT_API const long mlclient::SearchResultSet::getPageLength ( )

Returns the number of results returned on each page.

Note
MarkLogic Server defaults to 10 per page. This may or may not be the most performant option, depending on search options and thus amount of data returned per result. Try a higher number for better throughput for XML/JSON content.
This class will automatically fetch the next page of results until they are exhausted, so no need to handle this yourself.
Returns
The number of results returned per page.
MLCLIENT_API const std::string& mlclient::SearchResultSet::getQueryResolutionTime ( ) const

Returns the query resolution time for the last page requested, if available.

Defaults to zero. Uses xsd:duration string format as per the REST API

Returns
xsd:duration string description of the time to resolve the query
MLCLIENT_API const std::string& mlclient::SearchResultSet::getSnippetFormat ( ) const

Returns the snippet format. Could be raw, none, or snippet.

Returns
The string description as returned by the REST API. Usually "raw","none",or "snippet". Could be "custom" depending on search options.
MLCLIENT_API const std::string& mlclient::SearchResultSet::getSnippetResolutionTime ( ) const

Returns the snippet resolution time for the last page requested, if available.

Defaults to zero. Uses xsd:duration string format as per the REST API

Returns
xsd:duration string description of the time to resolve the snippet
MLCLIENT_API const long mlclient::SearchResultSet::getStart ( )

Returns the sequence number of the first search result.

Note
MarkLogic uses 1 based numbers. Thus the first record is at position 1, not position 0
Returns
The first result's sequence number (lowest is 1)
MLCLIENT_API const long mlclient::SearchResultSet::getTotal ( )

Returns the total count of all search results, across all pages.

Note
MarkLogic Server uses xdmp:estimate to calculate this. Thus for an accurate number your filtered xdmp estimate should be the same as your unfiltered xdmp estimate. I.e. should be completely calculable from indexes. Otherwise, this total could be higher than the actual number of results (after filtering).
Returns
The total number of search results returned.
MLCLIENT_API const std::string& mlclient::SearchResultSet::getTotalTime ( ) const

Returns the total time taken for the last page requested, if available.

Defaults to zero. Uses xsd:duration string format as per the REST API

Returns
xsd:duration string description of the total time taken (includes both snippet and query resolution time)
MLCLIENT_API void mlclient::SearchResultSet::setMaxResults ( long  maxResults)

Sets the maximum number of results to return. Useful if the maximum is larger than the page size.

Note
Limits the iterator return to max results

The documentation for this class was generated from the following file: