ePages 6.15.1 - DE_EPAGES/RemoteSearch/API/Object/SearchClient.pm

Package DE_EPAGES::RemoteSearch::API::Object::SearchClient

Client for searching.

Base
DE_EPAGES::RemoteSearch::API::Object::WebserviceClient

Functions

search
searchAsHash
searchAsObject

search

Search products with given parameters. Mandatory parameter are lang and query. Client sends query as HTTP POST request to the remote search service and return a HTTP::Response.
See also searchAsObject, searchAsHash. See also JAX-RS documentation of epagesJ.

Throws error 'REQUEST_FAILED' if remote service is not reachable or did not anwser in given the given timelimit. See DE_EPAGES::RemoteSearch::API::Object::HTTPClient

Syntax
my $Response = $Client->search( $hParams );
Example
my $Index   = $Shop->get('RemoteProductSearchIndex');
my $Client = $Index->remoteSearch();

# simple query
my $Response = $Client->search( {lang => 'en', query => 'tent' } );

# query with filters & error handling

my $Builder = DE_EPAGES::RemoteSearch::API::Object::SearchParamBuilder->new();
$Builder->query( $SearchString )
->lang( GetCodeByLanguageID( $Servlet->languageID ) )
->currency( $Servlet->currencyID )
->addSimpleFilter( 'manufacturer', $manufacturer );

my $Response2;
eval { $Response2 = $Client->search( $Builder->params() ); };
LogWarnings ('HTTP Request failed: ' . GetError() ) if ErrorExists();
if ($Response2){
# handle response
}
Input
$hParams
hash of oarans produced by
DE_EPAGES::RemoteSearch::API::Object::SearchParamBuilder. used keys:
  • query - mandatory, query string up to 255 chars, a zero length string must provided
    if no query string is available - string
  • lang - mandatory, 2 letter language code - string
  • currentPage - result page though your result list (default: 1) - integer
  • resultsPerPage - size of result page(default: 10) - integer
  • orderBy - 'relevance'(default), 'price', 'title' - string
  • sortOrder - 'desc' for descending, 'asc' for ascending - string

searchAsHash

Wrapper for $Client->search.

Syntax
my $hResult = $Client->searchAsHash( $hOptions );
Input
$hOptions (ref.hash)
see search
Return
$hResult (ref.hash)
search result as hash. Valid keys are:
  • items - results of current page - ref.array.hash
  • results - total number of search results - integer
  • query - query string - string
  • fallbackQuery - alternate query string used as fallback - string

searchAsObject

Wrapper for $Client->search.

Syntax
my $Response = $Client->searchAsObject( $hOptions, $hFilter );
Input
$hOptions (ref.hash)
see search
Return
$Response (DE_EPAGES::RemoteSearch::DTO::SearchResponse)
search result as object