MarkLogic Connect
MarkLogic Connect Client API Collection
Static Public Member Functions | List of all members
mlclient::utilities::SearchBuilder Class Reference

This class helps create a MarkLogic complex search JSON object for use with SearchDescription. More...

#include <SearchBuilder.hpp>

Public Member Functions

searchbuilder_classquery Instance factory methods that require class state in order to generate queries
MLCLIENT_API IQueryvalueQuery (const std::string ref, const std::string value)
 Creates a value query given the named reference. More...
 
MLCLIENT_API IQueryjsonValueQuery (const std::string ref, const std::string value)
 Creates a JSON property value query given the named reference. More...
 
MLCLIENT_API IQueryxmlValueQuery (const std::string ref, const std::string value)
 Creates an xml element value query given the named reference. More...
 
MLCLIENT_API IQueryrangeQuery (const std::string ref, const RangeOperation op, const std::string value)
 Creates a range query given the named reference, and range operation. More...
 
MLCLIENT_API IQueryjsonRangeQuery (const std::string ref, const RangeOperation op, const std::string value)
 Creates a JSON property range query given the named reference, and range operation. More...
 
MLCLIENT_API IQueryxmlRangeQuery (const std::string ref, const RangeOperation op, const std::string value)
 Creates an XML element range query given the named reference, and range operation. More...
 
searchbuilder_instance Instance methods that control the base search definition
MLCLIENT_API SearchBuildersetQuery (IQuery *query)
 Sets the root query for this search. More...
 
MLCLIENT_API void setDefaultXmlNamespace (const std::string &ns)
 Convenience method. Sets the default XML namespace for all XML queries. More...
 
MLCLIENT_API const std::string & getDefaultXmlNamespace () const
 Returns the default namespace. More...
 
MLCLIENT_API void setMode (const QueryBuilderMode mode)
 Sets the query builder mode, i.e. the format of the query. More...
 
MLCLIENT_API const QueryBuilderMode getMode () const
 Returns the current query builder format mode (JSON) More...
 
MLCLIENT_API ITextDocumentContenttoDocument ()
 Generates an ITextDocumentContent instance representing the serialisation of this structured query. More...
 

Static Public Member Functions

static MLCLIENT_API IQuerycollectionQuery (const CollectionSet &collections)
 Factory method. Creates a collection query instance. More...
 
static MLCLIENT_API IQuerydocumentQuery (const DocumentUriSet &uris)
 Factory method. Creates a Document Query instance. More...
 
searchbuilder_factory Public static class factory methods that control the create of a search or query
static MLCLIENT_API IQueryandQuery (const std::vector< IQuery * > &queries)
 Factory method. Creates an and-query. More...
 
static MLCLIENT_API IQueryorQuery (const std::vector< IQuery * > &queries)
 Factory method. Creates an or-query instance. More...
 
static MLCLIENT_API IQuerynotQuery (const IQuery *query)
 Factory method. Creates a not-query. More...
 

Detailed Description

This class helps create a MarkLogic complex search JSON object for use with SearchDescription.

Author
Adam Fowler adam..nosp@m.fowl.nosp@m.er@ma.nosp@m.rklo.nosp@m.gic.c.nosp@m.om
Since
8.0.2
Date
2016-06-08
Note
This class deals only with a complex search, NOT search options or text grammar.
This class only ever generates JSON output, never XML. This enables the class to be more efficient, using the same internal structures as required by a JSON stream.
This class has an external dependency on Microsoft's C++ cpprest API. As this API is required to use MarkLogic's C++ wrapper (this API) , this does not introduce any extra dependencies.

Member Function Documentation

static MLCLIENT_API IQuery* mlclient::utilities::SearchBuilder::andQuery ( const std::vector< IQuery * > &  queries)
static

Factory method. Creates an and-query.

Parameters
queriesA set of IQuery instances to and-together
Returns
An IQuery pointer instance representing this structured query. Caller OWNS the pointer (this class does not delete it).
static MLCLIENT_API IQuery* mlclient::utilities::SearchBuilder::collectionQuery ( const CollectionSet collections)
static

Factory method. Creates a collection query instance.

Parameters
collectionsThe set of collections specified for the query (an OR evaluated list)
Returns
An IQuery pointer instance representing this structured query. Caller OWNS the pointer (this class does not delete it).
static MLCLIENT_API IQuery* mlclient::utilities::SearchBuilder::documentQuery ( const DocumentUriSet uris)
static

Factory method. Creates a Document Query instance.

Parameters
urisThe DocumentUriSet (a vector<std::string>) listing the collections a document must be a member of (OR query)
Returns
An IQuery pointer instance representing this structured query. Caller OWNS the pointer (this class does not delete it).
MLCLIENT_API const std::string& mlclient::utilities::SearchBuilder::getDefaultXmlNamespace ( ) const

Returns the default namespace.

Returns
The default namespace string
MLCLIENT_API const QueryBuilderMode mlclient::utilities::SearchBuilder::getMode ( ) const

Returns the current query builder format mode (JSON)

Returns
The QueryBuilderMode in use (JSON)
MLCLIENT_API IQuery* mlclient::utilities::SearchBuilder::jsonRangeQuery ( const std::string  ref,
const RangeOperation  op,
const std::string  value 
)

Creates a JSON property range query given the named reference, and range operation.

Note
This method checks a list of named references, and thus is an instance method.
Parameters
refThe reference to check
opThe RangeOperation to perform
valueThe string value to match
Returns
The IQuery instance created. The caller OWNS this pointer. (This class does not delete the pointer.)
MLCLIENT_API IQuery* mlclient::utilities::SearchBuilder::jsonValueQuery ( const std::string  ref,
const std::string  value 
)

Creates a JSON property value query given the named reference.

Note
This method checks a list of named references, and thus is an instance method.
Parameters
refThe reference to check
valueThe string value to match
Returns
The IQuery instance created. The caller OWNS this pointer. (This class does not delete the pointer.)
static MLCLIENT_API IQuery* mlclient::utilities::SearchBuilder::notQuery ( const IQuery query)
static

Factory method. Creates a not-query.

Parameters
queryThe single query to not-query (pass it an or query to not anything where one of a set of queries match)
Returns
An IQuery pointer instance representing this structured query. Caller OWNS the pointer (this class does not delete it).
static MLCLIENT_API IQuery* mlclient::utilities::SearchBuilder::orQuery ( const std::vector< IQuery * > &  queries)
static

Factory method. Creates an or-query instance.

Parameters
queriesA set of IQuery instances to or-together
Returns
An IQuery pointer instance representing this structured query. Caller OWNS the pointer (this class does not delete it).
MLCLIENT_API IQuery* mlclient::utilities::SearchBuilder::rangeQuery ( const std::string  ref,
const RangeOperation  op,
const std::string  value 
)

Creates a range query given the named reference, and range operation.

Note
This method checks a list of named references, and thus is an instance method.
Parameters
refThe reference to check
opThe RangeOperation to perform
valueThe string value to match
Returns
The IQuery instance created. The caller OWNS this pointer. (This class does not delete the pointer.)
MLCLIENT_API void mlclient::utilities::SearchBuilder::setDefaultXmlNamespace ( const std::string &  ns)

Convenience method. Sets the default XML namespace for all XML queries.

Parameters
nsThe XML namespace full URI string
MLCLIENT_API void mlclient::utilities::SearchBuilder::setMode ( const QueryBuilderMode  mode)

Sets the query builder mode, i.e. the format of the query.

Warning
This should ALWAYS be JSON for now. XML queries are not yet supported.
Parameters
modeThe query format mode
MLCLIENT_API SearchBuilder* mlclient::utilities::SearchBuilder::setQuery ( IQuery query)

Sets the root query for this search.

Use and-query and or-query to join multiple queries together, then pass the result to this function.

Parameters
queryThe root query for this structured query
Returns
A chainable reference to this class instance, allowing for multiple calls and easy function calling.
MLCLIENT_API ITextDocumentContent* mlclient::utilities::SearchBuilder::toDocument ( )

Generates an ITextDocumentContent instance representing the serialisation of this structured query.

Returns
The ITextDocumentContent instance. Caller OWNS this pointer. (This class never deletes it)
MLCLIENT_API IQuery* mlclient::utilities::SearchBuilder::valueQuery ( const std::string  ref,
const std::string  value 
)

Creates a value query given the named reference.

Note
This method checks a list of named references, and thus is an instance method.
Parameters
refThe reference to check
valueThe string value to match
Returns
The IQuery instance created. The caller OWNS this pointer. (This class does not delete the pointer.)
MLCLIENT_API IQuery* mlclient::utilities::SearchBuilder::xmlRangeQuery ( const std::string  ref,
const RangeOperation  op,
const std::string  value 
)

Creates an XML element range query given the named reference, and range operation.

Note
This method checks a list of named references, and thus is an instance method.
Parameters
refThe reference to check
opThe RangeOperation to perform
valueThe string value to match
Returns
The IQuery instance created. The caller OWNS this pointer. (This class does not delete the pointer.)
MLCLIENT_API IQuery* mlclient::utilities::SearchBuilder::xmlValueQuery ( const std::string  ref,
const std::string  value 
)

Creates an xml element value query given the named reference.

Note
This method checks a list of named references, and thus is an instance method.
Parameters
refThe reference to check
valueThe string value to match
Returns
The IQuery instance created. The caller OWNS this pointer. (This class does not delete the pointer.)

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