com.konakart.bl
Class SolrMgr

java.lang.Object
  extended by com.konakart.bl.BaseMgr
      extended by com.konakart.bl.SolrMgr
All Implemented Interfaces:
SolrMgrIf

public class SolrMgr
extends BaseMgr
implements SolrMgrIf

Manager for code to interface with Solr


Nested Class Summary
protected  class SolrMgr.StaticData
          Used to store the static data of this manager
 
Field Summary
protected static java.lang.String AND
          Values used in Query
protected static java.lang.String CLOSE_BRACKETS
           
protected static java.lang.String COLON
           
protected static org.apache.commons.logging.Log log
          the log
protected static java.lang.String LUCENE_ESCAPE_CHARS
          Lucene constants
protected static java.util.regex.Pattern LUCENE_PATTERN
           
protected static java.lang.String mutex
           
protected static java.lang.String OPEN_BRACKETS
           
protected static java.lang.String OR
           
protected static java.lang.String POST_ENCODING
           
protected static int QUERY_SELECT
          Type of Query
protected static int QUERY_TERM
           
protected static java.lang.String REPLACEMENT_STRING
           
protected static java.util.Map<java.lang.String,SolrMgr.StaticData> staticDataHM
          Hash Map that contains the static data
protected static java.lang.String TO
           
 
Fields inherited from class com.konakart.bl.BaseMgr
templateBaseDir
 
Constructor Summary
SolrMgr(KKEngIf eng)
          Constructor
 
Method Summary
protected  java.lang.String beforeSendQuery(java.lang.String sessionId, java.lang.String queryString, DataDescriptorIf dataDesc, ProductSearchIf prodSearch, int languageId)
          Method that can be used to customize the query string.
protected  java.lang.String escapeSearchString(java.lang.String searchString)
          The Lucene search engine requires the following characters to be escaped: + - ! ( ) { } [ ] ^ " ~ * ? : \
protected  java.lang.String getCustomSearchString(java.math.BigDecimal searchDec, int rule, int customFieldNum)
          Creates a search string based on the rule.
protected  java.lang.String getCustomSearchString(java.lang.Integer searchInt, int rule, int customFieldNum)
          Creates a search string based on the rule.
protected  java.lang.String getCustomSearchString(java.lang.String searchString, int rule, int customFieldNum)
          Creates a search string based on the rule.
protected  java.net.URL getSolrSelectUrl(java.lang.String cmd, int type)
          Get the Solr Url For selecting data
protected  java.net.URL getSolrUpdateUrl()
          Get the Solr Url For updating data
 SuggestedSearchItem[] getSuggestedSearchItems(java.lang.String sessionId, SuggestedSearchOptionsIf options)
          Method that uses SOLR Terms in order to get suggested search data based on a search string.
protected  java.lang.String getTextSearchString(java.lang.String searchString, int rule)
          Creates a search string based on the rule.
 void refreshConfigs()
          Get the config variables needed to setup the Solr mgr
 void removeProductFromSearchEngine(int productId)
          Remove a single product referenced by productId from the Solr search engine
 SolrProducts searchForProducts(java.lang.String sessionId, DataDescriptorIf dataDesc, ProductSearchIf prodSearch, int priceId, int languageId)
          This method only gets called if the Solr search engine is activated and if the prodSearch contains some text.
protected  java.lang.String sendQueryToSolr(java.lang.String query, int type)
           
 boolean useSolr()
          Returns true if Solr can be used, otherwise it returns false
 
Methods inherited from class com.konakart.bl.BaseMgr
addInsertAttr, addInsertAttr, checkRequired, getAdminEngMgr, getBasketMgr, getBillingMgr, getBookableProductMgr, getCatMgr, getConfigMgr, getCookieMgr, getCurrMgr, getCustMgr, getCustomerIdFromSession, getCustomerStatsMgr, getCustomerTagMgr, getEmailMgr, getEng, getLangMgr, getManuMgr, getMiscItemMgr, getMode, getModeString, getMqMgr, getMultiStoreMgr, getNewCriteria, getNewCriteria, getOrderMgr, getOrderTotalMgr, getPaymentMgr, getProdMgr, getPromMgr, getRewardPointMgr, getSecMgr, getShippingMgr, getSolrMgr, getStoreId, getTaxMgr, getTemplate, getTemplateRoot, getVelocityContextMgr, getWishListMgr, init, isEnterprise, isMultiStoreShareCustomers, isMultiStoreShareProducts
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

protected static org.apache.commons.logging.Log log
the log


staticDataHM

protected static java.util.Map<java.lang.String,SolrMgr.StaticData> staticDataHM
Hash Map that contains the static data


QUERY_SELECT

protected static final int QUERY_SELECT
Type of Query

See Also:
Constant Field Values

QUERY_TERM

protected static final int QUERY_TERM
See Also:
Constant Field Values

AND

protected static final java.lang.String AND
Values used in Query

See Also:
Constant Field Values

OR

protected static final java.lang.String OR
See Also:
Constant Field Values

TO

protected static final java.lang.String TO
See Also:
Constant Field Values

COLON

protected static final java.lang.String COLON
See Also:
Constant Field Values

OPEN_BRACKETS

protected static final java.lang.String OPEN_BRACKETS
See Also:
Constant Field Values

CLOSE_BRACKETS

protected static final java.lang.String CLOSE_BRACKETS
See Also:
Constant Field Values

POST_ENCODING

protected static final java.lang.String POST_ENCODING
See Also:
Constant Field Values

LUCENE_ESCAPE_CHARS

protected static final java.lang.String LUCENE_ESCAPE_CHARS
Lucene constants

See Also:
Constant Field Values

LUCENE_PATTERN

protected static final java.util.regex.Pattern LUCENE_PATTERN

REPLACEMENT_STRING

protected static final java.lang.String REPLACEMENT_STRING
See Also:
Constant Field Values

mutex

protected static java.lang.String mutex
Constructor Detail

SolrMgr

public SolrMgr(KKEngIf eng)
        throws java.lang.Exception
Constructor

Parameters:
eng -
Throws:
java.lang.Exception
Method Detail

getSuggestedSearchItems

public SuggestedSearchItem[] getSuggestedSearchItems(java.lang.String sessionId,
                                                     SuggestedSearchOptionsIf options)
                                              throws java.lang.Exception
Method that uses SOLR Terms in order to get suggested search data based on a search string.

Specified by:
getSuggestedSearchItems in interface SolrMgrIf
Parameters:
sessionId -
options -
Returns:
Returns an array of SuggestedSearchItems
Throws:
KKException
java.lang.Exception

searchForProducts

public SolrProducts searchForProducts(java.lang.String sessionId,
                                      DataDescriptorIf dataDesc,
                                      ProductSearchIf prodSearch,
                                      int priceId,
                                      int languageId)
                               throws java.lang.Exception
This method only gets called if the Solr search engine is activated and if the prodSearch contains some text.

Specified by:
searchForProducts in interface SolrMgrIf
Parameters:
sessionId -
dataDesc -
prodSearch -
priceId -
languageId -
Returns:
Returns an array of integers for the products that have been found
Throws:
java.lang.Exception

beforeSendQuery

protected java.lang.String beforeSendQuery(java.lang.String sessionId,
                                           java.lang.String queryString,
                                           DataDescriptorIf dataDesc,
                                           ProductSearchIf prodSearch,
                                           int languageId)
                                    throws java.lang.Exception
Method that can be used to customize the query string. The query string does not include the SOLR URL.

Parameters:
sessionId - The sessionId of the logged in user
queryString - Query string that will be sent to SOLR
dataDesc - DataDescriptor object
prodSearch - ProductSearch object which may be null
languageId - Language id
Returns:
Returns the customized query string
Throws:
java.lang.Exception

sendQueryToSolr

protected java.lang.String sendQueryToSolr(java.lang.String query,
                                           int type)
                                    throws org.apache.torque.TorqueException,
                                           com.workingdogs.village.DataSetException,
                                           java.lang.Exception
Parameters:
query - The parameters for the HTTP GET
type - The type of query
Returns:
Returns the SOLR response
Throws:
java.lang.Exception
com.workingdogs.village.DataSetException
org.apache.torque.TorqueException

removeProductFromSearchEngine

public void removeProductFromSearchEngine(int productId)
                                   throws org.apache.torque.TorqueException,
                                          com.workingdogs.village.DataSetException,
                                          java.lang.Exception
Remove a single product referenced by productId from the Solr search engine

Specified by:
removeProductFromSearchEngine in interface SolrMgrIf
Parameters:
productId -
Throws:
org.apache.torque.TorqueException
com.workingdogs.village.DataSetException
java.lang.Exception

getSolrSelectUrl

protected java.net.URL getSolrSelectUrl(java.lang.String cmd,
                                        int type)
                                 throws org.apache.torque.TorqueException,
                                        com.workingdogs.village.DataSetException,
                                        java.lang.Exception
Get the Solr Url For selecting data

Parameters:
cmd -
type - The type of query
Returns:
Returns the Solr Url
Throws:
org.apache.torque.TorqueException
com.workingdogs.village.DataSetException
java.lang.Exception

getSolrUpdateUrl

protected java.net.URL getSolrUpdateUrl()
                                 throws org.apache.torque.TorqueException,
                                        com.workingdogs.village.DataSetException,
                                        java.lang.Exception
Get the Solr Url For updating data

Returns:
Returns the Solr Url
Throws:
org.apache.torque.TorqueException
com.workingdogs.village.DataSetException
java.lang.Exception

refreshConfigs

public void refreshConfigs()
                    throws java.lang.Exception
Get the config variables needed to setup the Solr mgr

Specified by:
refreshConfigs in interface SolrMgrIf
Throws:
java.lang.Exception

useSolr

public boolean useSolr()
                throws KKException
Returns true if Solr can be used, otherwise it returns false

Specified by:
useSolr in interface SolrMgrIf
Returns:
Returns true if Solr can be used, otherwise it returns false
Throws:
KKException

getTextSearchString

protected java.lang.String getTextSearchString(java.lang.String searchString,
                                               int rule)
Creates a search string based on the rule. Adds wild cards if necessary.

Parameters:
searchString -
rule -
Returns:
Returns a search string with wild cards if appropriate

getCustomSearchString

protected java.lang.String getCustomSearchString(java.lang.String searchString,
                                                 int rule,
                                                 int customFieldNum)
Creates a search string based on the rule. Adds wild cards if necessary.

Parameters:
searchString - The search string
rule - The rule for determining whether to introduce a wild card
customFieldNum - Used to detect which custom field is being used
Returns:
Returns a search string with wild cards if appropriate

getCustomSearchString

protected java.lang.String getCustomSearchString(java.lang.Integer searchInt,
                                                 int rule,
                                                 int customFieldNum)
Creates a search string based on the rule.

Parameters:
searchInt - The search integer
rule - The rule for determining whether to introduce less than, greater than etc.
customFieldNum - Used to detect which custom field is being used
Returns:
Returns a search string for solr

getCustomSearchString

protected java.lang.String getCustomSearchString(java.math.BigDecimal searchDec,
                                                 int rule,
                                                 int customFieldNum)
Creates a search string based on the rule.

Parameters:
searchDec - The search Big Decimal
rule - The rule for determining whether to introduce less than, greater than etc.
customFieldNum - Used to detect which custom field is being used
Returns:
Returns a search string for solr

escapeSearchString

protected java.lang.String escapeSearchString(java.lang.String searchString)
The Lucene search engine requires the following characters to be escaped: + - ! ( ) { } [ ] ^ " ~ * ? : \

Parameters:
searchString -
Returns:
Returns the escaped string


Copyright © 2011 DS Data Systems UK Ltd.