ePages 6.14.0 - DE_EPAGES/RemoteSearch/API/Object/SuggestClient.pm

Package DE_EPAGES::RemoteSearch::API::Object::SuggestClient

Client for suggestions

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

Functions

suggest
suggestAsHash
suggestUrl

suggest

Calls suggestion service via HTTP GET and returns HTTP::Response.

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->suggest( $query, $lang );
Example

my $Index   = $Shop->get('RemoteProductSearchIndex');
my $Suggest = $Index->remoteSuggest();
my $Response;

eval { $Response = $Suggest->suggest('tent', 'en'); };
LogWarnings ('HTTP Request failed: ' . GetError() ) if ErrorExists();
if ($Response){
# handle response
}
Input
$query (string)
query string
$lang (string)
2-digit language code
Return
$Response (HTTP::Response)
HTTP response

suggestAsHash

Wrapper for $Client->suggest, returns http content decoded as hash

Syntax
my $hSuggestions = $Client->suggestAsHash( $query, $lang );
Input
$query (string)
query string
$lang (string)
2-digit language code
Return
$hSuggestions (ref.hash)
suggestions response. used keys:
  • products - products - ref.array.hash
  • categories - categories - ref.array.hash
  • manufacturers - manufacturers - ref.array.hash

suggestUrl

Builds the url used by suggestion webservice

Syntax
my $URL = $Client->suggestUrl( $query, $lang );
Input
$query (string)
query string
$lang (string)
2-digit language code
Return
$url (string)
sebservice url