ePages 6.15.1 - DE_EPAGES/RemoteSearch/API/RemoteSearchImpl.pm

Package DE_EPAGES::RemoteSearch::API::RemoteSearchImpl

High level API used by scripts from the RemoteSearch cartridge

Base
Exporter
@EXPORT_OK
DropAllSearchIndexes
GetOrCreateSearchIndex
GetUserAgent
GUIDforObjectID
IsRemoteSearchActive
MarkShopDirty
RunIfRemoteSearchInitialized
SearchProducts
SearchProductsFallback
UpdateSearchStatistics

Functions

DropAllSearchIndexes
GUIDforObjectID
GetOrCreateSearchIndex
GetUserAgent
IsRemoteSearchActive
MarkShopDirty
RunIfRemoteSearchInitialized
SearchProducts
SearchProductsFallback
UpdateSearchStatistics

DropAllSearchIndexes

Resets search info on shop and tries to delete the index from the remote search, if needed.

Syntax
DropAllSearchIndexes( $Shop );
DropAllSearchIndexes( $Shop, $DropRemote );
Input
$Shop (object)
Shop
$DropRemote (boolean)
(optional, default: false; set to true, if you want to remove the remote index

GUIDforObjectID

Get corrosponding GUIDs for list of objectIDs

Syntax
my $aGUIDs = GUIDforObjectID( $aIDList );
Input
$aIDList (ref.array)
list of objectIDs
Return
$aGUIDs (ref.array)
list of GUIDs

GetOrCreateSearchIndex

Creates (if necessary) and returns SearchIndex object. Does not set the remote call to index the shop. Use DE_EPAGES::RemoteSearch::API::Object::IndexManager for that.

Syntax
my $SearchIndex = GetOrCreateSearchIndex( $Shop );
Input
$Shop (DE_EPAGES::Shop::API::Object::Shop)
Shop object
Return
$SearchIndex (DE_EPAGES::RemoteSearch::API::Object::SearchIndex)
search index

GetUserAgent

Configure and return an LWP::UserAgent instance. Reads epages.conf sections to configure this object. Used configuration: [DE_EPAGES::RemoteSearch] HTTPTimeOut = 10; default timeout is 10 sec

Syntax
my $UserAgent = GetUserAgent();
Return
$UserAgent (LWP::UserAgent)
configured LWP::UserAgent

IsRemoteSearchActive

Check if remote search can be used for the shop

Syntax
my $IsUseable = IsRemoteSearchActive( $Shop );
Input
$Shop (DE_EPAGES::Shop::API::Object::Shop)
Shop object
Return
$IsActive (Boolean)
Returns true if System and $Shop flagged have set RemoteSearchEnabled

MarkShopDirty

Mark (existing) search index of $Shop as dirty.

Syntax
MarkShopDirty( $Shop );
Input
$Shop (object DE_EPAGES::Shop::API::Object::Shop)
shop object

RunIfRemoteSearchInitialized

Runs code if remote search is active and RemoteSearchIndex object has been created. Passes RemoteProductSearchIndex object into the sub. Non-fatal Errors get turned into Warnings.

Syntax
RunIfRemoteSearchInitialized( $Shop, $cSub );
Example
RunIfRemoteSearchActive($Shop, sub {
    my ($Search) = @_;
    $Search->updateItems([ $Product ]);
});
Input
$Shop (DE_EPAGES::Shop::API::Object::Shop)
shop
$cSub (ref.code)
code ref

SearchProducts

Execute product search in $Shop. See DE_EPAGES::RemoteSearch::API::Object::SearchParamBuilder for configuration options.

Syntax
SearchProducts( $Shop, $ParamBuilder );
Input
$Shop (DE_EPAGES::Shop::API::Object::Shop)
shop which should be searched
$ParamBuilder (DE_EPAGES::RemoteSearch::API::Object::SearchParamBuilder)
all setttings for search
Return
$ReturnVariable (ref.hash.)
result with object ids and facets data

SearchProductsFallback

This method is deprecated and may be removed in near future!
Construct an PagerSearchMulti, which can execute a product search with SQL. Use of this method should limited to fallback solution if SearchProducts is failing. Keep in mind the SQL fallback execute strict *PATTERN* search, which will lead to heavy load on database and may take long time to yield a result.

Syntax
$Pager = SearchProductsFallback( $Shop, $ParamBuilder );
Input
$Servlet (object)
Servlet of current context
$ParamBuilder (DE_EPAGES::RemoteSearch::API::Object::SearchParamBuilder)
Search options
Return
$Pager (DE_EPAGES::Search::API::Object::PagerSearchMulti)
Pager which can execute an SQL search

UpdateSearchStatistics

Registers the user's search query at our search statistics.

Search services automatically provides a fallback if a multi-term query yields to no results, by throwing out the last term of the query and repeating the search. If the fallback kicks in, $Result contains the fallback query used.

Syntax
UpdateSearchStatistics( $Servlet, $Response );
Input
$Servlet (object)
current servlet
$Response (DE_EPAGES::RemoteSearch::API::DTO::SearchResponse)
search response