Modifier and Type | Class and Description |
---|---|
protected class |
SolrMgr.MultiValuedTagGroup
Used to store a list of multi valued tag groups
|
protected class |
SolrMgr.StaticData
Used to store the static data of this manager
|
Modifier and Type | Field and Description |
---|---|
protected static java.lang.String |
AND
Value used in Query
|
protected static java.util.regex.Pattern |
AND_PATTERN
Lucene constant
|
protected static java.lang.String |
CLOSE_BRACKETS
Value used in Query
|
protected static java.lang.String |
COLON
Value used in Query
|
protected static org.apache.commons.logging.Log |
log
the log
|
protected static java.lang.String |
LUCENE_ESCAPE_CHARS
Lucene constant
|
protected static java.util.regex.Pattern |
LUCENE_PATTERN
Lucene constant
|
protected static java.lang.String |
mutex
Mutex
|
protected static java.util.regex.Pattern |
NOT_PATTERN
Lucene constant
|
protected static java.lang.String |
OPEN_BRACKETS
Value used in Query
|
protected static java.lang.String |
OR
Value used in Query
|
protected static java.util.regex.Pattern |
OR_PATTERN
Lucene constant
|
protected static java.lang.String |
POST_ENCODING
Value used in Query
|
protected static int |
QUERY_SELECT
Type of Query
|
protected static int |
QUERY_TERM
Type of Query
|
protected static java.lang.String |
REPLACEMENT_STRING
Lucene constant
|
protected static java.lang.String |
START
Value used in Query
|
protected static java.util.Map<java.lang.String,SolrMgr.StaticData> |
staticDataHM
Hash Map that contains the static data
|
protected static java.lang.String |
TO
Value used in Query
|
protected static java.util.regex.Pattern |
TOKENIZER_PATTERN
Lucene constant
|
templateBaseDir
Modifier and Type | Method and Description |
---|---|
protected void |
appendAND(java.lang.StringBuffer sb)
Utility method to only append an AND if it isn't the first constraint being added to the
query
|
protected java.lang.String |
beforeSendQuery(java.lang.String sessionId,
java.lang.String queryString,
DataDescriptorIf dataDesc,
ProductSearchIf prodSearch,
int languageId,
FetchProductOptionsIf options)
Method that can be used to customize the query string.
|
java.lang.String |
escapeSearchString(java.lang.String searchString)
The Lucene search engine requires the following characters to be escaped: + - ! ( ) { } [ ] ^
" ~ * ? : \
|
protected java.lang.String |
getAttr(org.w3c.dom.Node node,
java.lang.String name)
Utility method for retrieving the value of an attribute from a node
|
protected NameNumber[] |
getChildIntData(org.w3c.dom.Node parent,
java.util.HashMap<java.lang.Integer,java.math.BigDecimal> scoreMap)
Utility method to process XML similar to example below:
|
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.math.BigDecimal |
getDec(java.math.BigDecimal in,
int scale)
Utility method to make code more readable
|
protected java.math.BigDecimal |
getDec(java.lang.String in,
int scale)
Utility method to make code more readable
|
protected java.net.URL |
getSolrSelectUrl(java.lang.String cmd,
int type,
java.lang.String action)
Get the Solr Url For selecting data
|
protected java.net.URL |
getSolrUpdateUrl()
Get the Solr Url For updating data
|
java.lang.String |
getSolrUrl()
Get the Solr URL.
|
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.
|
SuggestedSpellingItem[] |
getSuggestedSpellingItems(java.lang.String sessionId,
SuggestedSpellingOptionsIf options)
Method that uses SOLR in order to get suggested spelling 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.
|
protected void |
getTokenizedSearchString(java.lang.StringBuffer querySb,
java.lang.String attr,
java.lang.String[] tokenArray)
Utility method to avoid duplicating code
|
protected boolean |
isAttr(org.w3c.dom.Node node,
java.lang.String name,
java.lang.String value)
Utility method for determining whether an attribute exists
|
SolrProducts |
parseReply(java.lang.String xmlReply,
ProductSearchIf prodSearch,
int langId)
A DOM structure is created from the XML reply.
|
protected void |
processChildren(org.w3c.dom.NodeList nList,
SolrProducts sProds,
ProductSearchIf prodSearch,
int langId)
Process the child nodes of the node passed in as a parameter
|
protected void |
processFacets(org.w3c.dom.Node cNode,
SolrProducts sProds,
ProductSearchIf prodSearch,
int langId)
Process XML similar to example below:
|
protected void |
processNode(org.w3c.dom.Node cNode,
SolrProducts sProds,
ProductSearchIf prodSearch,
int langId)
We identify the node and process it to retrieve information.
|
protected void |
processPriceFacets(org.w3c.dom.Node cNode,
SolrProducts sProds,
ProductSearchIf prodSearch)
Process XML similar to sample below:
|
protected void |
processProducts(org.w3c.dom.Node cNode,
SolrProducts sProds)
Process XML similar to example below.
|
protected void |
processSnippets(org.w3c.dom.Node cNode,
SolrProducts sProds)
Process XML similar to sample below:
|
protected void |
processStats(org.w3c.dom.Node cNode,
SolrProducts sProds)
Process XML similar to sample below:
|
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,
FetchProductOptionsIf options)
This method only gets called if the Solr search engine is activated and if the prodSearch
contains some text.
|
java.lang.String |
sendQueryToSolr(java.lang.String query,
int type,
java.lang.String action)
Sends the query to Solr.
|
java.lang.String |
sendQueryToSolr(java.lang.String query,
int type,
java.lang.String action,
int attempt)
Sends the query to Solr
|
protected void |
traverse(org.w3c.dom.Node cNode,
SolrProducts sProds,
ProductSearchIf prodSearch,
int langId)
The start method for processing the DOM structure
|
boolean |
useSolr()
Returns true if Solr can be used, otherwise it returns false
|
acquireLock, addInsertAttr, addInsertAttr, addStringRuleConstraint, addStringRuleConstraint, checkRequired, escapeHTML, executeQuery, executeQuery, executeQuery, executeQuery, executeQuery, getAdminEngMgr, getBasketMgr, getBillingMgr, getBookableProductMgr, getCacheMgr, getCatMgr, getConfigMgr, getCookieMgr, getCurrMgr, getCustMgr, getCustomerIdFromSession, getCustomerStatsMgr, getCustomerTagMgr, getEmailMgr, getEng, getEventMgr, getExportMgr, getHTMLEscaper, getKonaKartConfig, getKonaKartConfig, getKonaKartConfig, getLangMgr, getManuMgr, getMiscItemMgr, getMiscPriceMgr, getMode, getModeString, getMqMgr, getMultiStoreMgr, getNewCriteria, getNewCriteria, getOrderIntegrationMgr, getOrderMgr, getOrderTotalMgr, getPaymentMgr, getProdMgr, getProductsToCategoresCriteria, getPromMgr, getPunchOutMgr, getRewardPointMgr, getSecMgr, getShippingMgr, getSolrMgr, getStoreId, getStoreMgr, getStoreTime, getSuggestionMgr, getTaxMgr, getTemplate, getTemplateRoot, getVelocityContextMgr, getWishListMgr, init, insertKKEvent, insertKKEvent, isBusiness, isBusinessOrEnterprise, isClassPresent, isCommunity, isDeadlockException, isEnterprise, isMultiStoreShareCategories, isMultiStoreShareCustomers, isMultiStoreShareCustomersOrProducts, isMultiStoreSharedDb, isMultiStoreShareProducts, isMultiVendor, isUnix, manageThrowable, releaseLock, updateStaticVariablesNow
protected static org.apache.commons.logging.Log log
protected static java.util.Map<java.lang.String,SolrMgr.StaticData> staticDataHM
protected static final int QUERY_SELECT
protected static final int QUERY_TERM
protected static final java.lang.String START
protected static final java.lang.String AND
protected static final java.lang.String OR
protected static final java.lang.String TO
protected static final java.lang.String COLON
protected static final java.lang.String OPEN_BRACKETS
protected static final java.lang.String CLOSE_BRACKETS
protected static final java.lang.String POST_ENCODING
protected static final java.lang.String LUCENE_ESCAPE_CHARS
protected static final java.util.regex.Pattern LUCENE_PATTERN
protected static final java.util.regex.Pattern AND_PATTERN
protected static final java.util.regex.Pattern OR_PATTERN
protected static final java.util.regex.Pattern NOT_PATTERN
protected static final java.lang.String REPLACEMENT_STRING
protected static final java.util.regex.Pattern TOKENIZER_PATTERN
protected static java.lang.String mutex
public SolrMgr(KKEngIf eng) throws java.lang.Exception
eng
- the engjava.lang.Exception
- an unexpected exceptionpublic SuggestedSearchItem[] getSuggestedSearchItems(java.lang.String sessionId, SuggestedSearchOptionsIf options) throws java.lang.Exception
getSuggestedSearchItems
in interface SolrMgrIf
sessionId
- the sessionIdoptions
- the optionsjava.lang.Exception
- an unexpected exceptionpublic SuggestedSpellingItem[] getSuggestedSpellingItems(java.lang.String sessionId, SuggestedSpellingOptionsIf options) throws java.lang.Exception
getSuggestedSpellingItems
in interface SolrMgrIf
sessionId
- the sessionIdoptions
- the optionsjava.lang.Exception
- an unexpected exceptionpublic SolrProducts searchForProducts(java.lang.String sessionId, DataDescriptorIf dataDesc, ProductSearchIf prodSearch, int priceId, int languageId, FetchProductOptionsIf options) throws java.lang.Exception
searchForProducts
in interface SolrMgrIf
sessionId
- the sessionIddataDesc
- the dataDescprodSearch
- the prodSearchpriceId
- the priceIdlanguageId
- the languageIdoptions
- the optionsjava.lang.Exception
- an unexpected exceptionprotected void getTokenizedSearchString(java.lang.StringBuffer querySb, java.lang.String attr, java.lang.String[] tokenArray)
querySb
- the querySbattr
- the attrtokenArray
- the tokenArraypublic SolrProducts parseReply(java.lang.String xmlReply, ProductSearchIf prodSearch, int langId) throws java.lang.Exception
parseReply
in interface SolrMgrIf
xmlReply
- the xmlReplyprodSearch
- the prodSearchlangId
- the langIdjava.lang.Exception
- an unexpected exceptionprotected void traverse(org.w3c.dom.Node cNode, SolrProducts sProds, ProductSearchIf prodSearch, int langId) throws java.lang.Exception
cNode
- the cNodesProds
- the sProdsprodSearch
- the prodSearchlangId
- the langIdjava.lang.Exception
- an unexpected exceptionprotected void processChildren(org.w3c.dom.NodeList nList, SolrProducts sProds, ProductSearchIf prodSearch, int langId) throws java.lang.Exception
nList
- the nListsProds
- the sProdsprodSearch
- the prodSearchlangId
- the langIdjava.lang.Exception
- an unexpected exceptioncom.konakart.app.KKException
- an unexpected KKException exceptionprotected void processNode(org.w3c.dom.Node cNode, SolrProducts sProds, ProductSearchIf prodSearch, int langId) throws java.lang.Exception
cNode
- the cNodesProds
- the sProdsprodSearch
- the prodSearchlangId
- the langIdjava.lang.Exception
- an unexpected exceptioncom.konakart.app.KKException
- an unexpected KKException exceptionprotected void processProducts(org.w3c.dom.Node cNode, SolrProducts sProds)
<result name="response" numFound="5" start="0" maxScore="3.334529" >
<doc>
<int name="id">23</int>
</doc>
<doc>
<int name="id">20</int>
</doc>
<doc>
<int name="id">6</int>
</doc>
<doc>
<int name="id">11</int>
</doc>
<doc>
<int name="id">4</int>
</doc>
</result>
cNode
- the cNodesProds
- the sProdsprotected void processSnippets(org.w3c.dom.Node cNode, SolrProducts sProds)
<lst name="highlighting">
<lst name="10">
<arr name="desc_en">
<str> 11.8% of total employment in <b>Aberdeen</b> City, 11</str><
<str> 11.8% of total employment in <b>Aberdeen</b> City, 11</str>
</arr>
<lst name="34">
<arr name="desc_en">
<str> 11.8% of total employment in <b>Aberdeen</b> City, 11</str>
</arr>
</lst>
</lst>
cNode
- the cNodesProds
- the sProdsprotected void processFacets(org.w3c.dom.Node cNode, SolrProducts sProds, ProductSearchIf prodSearch, int langId) throws java.lang.Exception
<lst name="facet_fields">
<lst name="manu_id">
<int name="3">3</int>
<int name="8">1</int>
<int name="11">1</int>
</lst>
<lst name="cat_id">
<int name="10">3</int>
<int name="15">1</int>
<int name="20">1</int>
</lst>
<lst name="facet_1">
<int name="aaa">3</int>
</lst>
<lst name="facet_2">
<int name="bbb">2</int>
<int name="eee">1</int>
</lst>
<lst name="facet_30">
<int name="ccc">1</int>
<int name="ddd">1</int>
<int name="fff">1</int>
</lst>
</lst>
cNode
- the cNodesProds
- the sProdsprodSearch
- the prodSearchlangId
- the langIdjava.lang.Exception
- an unexpected exceptionprotected void processPriceFacets(org.w3c.dom.Node cNode, SolrProducts sProds, ProductSearchIf prodSearch) throws java.lang.Exception
<lst name="facet_ranges">
<lst name="price0">
<lst name="counts">
<int name="20.0">2</int>
<int name="30.0">1</int>
<int name="50.0">1</int>
<int name="90.0">1</int>
</lst>
<float name="gap">10.0</float>
<float name="start">0.0</float>
<float name="end">50000.0</float>
</lst>
</lst>
cNode
- the cNodesProds
- the sProdsprodSearch
- the prodSearchjava.lang.Exception
- an unexpected exceptionprotected java.math.BigDecimal getDec(java.lang.String in, int scale)
in
- the inscale
- the scaleprotected java.math.BigDecimal getDec(java.math.BigDecimal in, int scale)
in
- the inscale
- the scaleprotected void processStats(org.w3c.dom.Node cNode, SolrProducts sProds)
<lst name="stats_fields">
<lst name="price0">
<double name="min">29.989999771118164</double>
<double name="max">54.9900016784668</double>
<long name="count">3</long>
<long name="missing">0</long>
<double name="sum">116.98000144958496</double>
<double name="sumOfSquares">4947.300370869449</double>
<double name="mean">38.99333381652832</double>
<double name="stddev">13.889926646455255</double>
<lst name="facets"/>
</lst>
</lst>
cNode
- the cNodesProds
- the sProdsprotected NameNumber[] getChildIntData(org.w3c.dom.Node parent, java.util.HashMap<java.lang.Integer,java.math.BigDecimal> scoreMap)
<int name="ccc">1</int>
<int name="ddd">1</int>
<int name="fff">1</int>
parent
- the parentscoreMap
- the scoreMapprotected java.lang.String getAttr(org.w3c.dom.Node node, java.lang.String name)
node
- the nodename
- the nameprotected boolean isAttr(org.w3c.dom.Node node, java.lang.String name, java.lang.String value)
node
- the nodename
- the namevalue
- the valueprotected void appendAND(java.lang.StringBuffer sb)
sb
- the sbprotected java.lang.String beforeSendQuery(java.lang.String sessionId, java.lang.String queryString, DataDescriptorIf dataDesc, ProductSearchIf prodSearch, int languageId, FetchProductOptionsIf options) throws java.lang.Exception
sessionId
- The sessionId of the logged in userqueryString
- Query string that will be sent to SOLRdataDesc
- DataDescriptor objectprodSearch
- ProductSearch object which may be nulllanguageId
- Language idoptions
- a FetchProductOptions object which may be nulljava.lang.Exception
- an unexpected exceptionpublic java.lang.String sendQueryToSolr(java.lang.String query, int type, java.lang.String action) throws org.apache.torque.TorqueException, com.workingdogs.village.DataSetException, java.lang.Exception
sendQueryToSolr
in interface SolrMgrIf
query
- The parameters for the HTTP GETtype
- The type of queryaction
- The action for the query. Type is ignored if action is not null.java.lang.Exception
- an unexpected exceptioncom.workingdogs.village.DataSetException
- an unexpected exception due to data in Torque (the database layer)org.apache.torque.TorqueException
- an unexpected exception in Torque (the database layer)public java.lang.String sendQueryToSolr(java.lang.String query, int type, java.lang.String action, int attempt) throws org.apache.torque.TorqueException, com.workingdogs.village.DataSetException, java.lang.Exception
sendQueryToSolr
in interface SolrMgrIf
query
- The parameters for the HTTP GETtype
- The type of queryaction
- The action for the query. Type is ignored if action is not null.attempt
- indicates the attempt number when Solr calls are retriedjava.lang.Exception
- an unexpected exceptioncom.workingdogs.village.DataSetException
- an unexpected exception due to data in Torque (the database layer)org.apache.torque.TorqueException
- an unexpected exception in Torque (the database layer)public void removeProductFromSearchEngine(int productId) throws org.apache.torque.TorqueException, com.workingdogs.village.DataSetException, java.lang.Exception
removeProductFromSearchEngine
in interface SolrMgrIf
productId
- the productIdorg.apache.torque.TorqueException
- an unexpected exception in Torque (the database layer)com.workingdogs.village.DataSetException
- an unexpected exception due to data in Torque (the database layer)java.lang.Exception
- an unexpected exceptionprotected java.net.URL getSolrSelectUrl(java.lang.String cmd, int type, java.lang.String action) throws org.apache.torque.TorqueException, com.workingdogs.village.DataSetException, java.lang.Exception
cmd
- the cmdtype
- The type of queryaction
- The action for the query. Type is ignored if action is not null.org.apache.torque.TorqueException
- an unexpected exception in Torque (the database layer)com.workingdogs.village.DataSetException
- an unexpected exception due to data in Torque (the database layer)java.lang.Exception
- an unexpected exceptionprotected java.net.URL getSolrUpdateUrl() throws org.apache.torque.TorqueException, com.workingdogs.village.DataSetException, java.lang.Exception
org.apache.torque.TorqueException
- an unexpected exception in Torque (the database layer)com.workingdogs.village.DataSetException
- an unexpected exception due to data in Torque (the database layer)java.lang.Exception
- an unexpected exceptionpublic void refreshConfigs() throws java.lang.Exception
refreshConfigs
in interface SolrMgrIf
java.lang.Exception
- an unexpected exceptionpublic boolean useSolr() throws com.konakart.app.KKException
protected java.lang.String getTextSearchString(java.lang.String searchString, int rule)
searchString
- the searchStringrule
- the ruleprotected java.lang.String getCustomSearchString(java.lang.String searchString, int rule, int customFieldNum)
searchString
- The search stringrule
- The rule for determining whether to introduce a wild cardcustomFieldNum
- Used to detect which custom field is being usedprotected java.lang.String getCustomSearchString(java.lang.Integer searchInt, int rule, int customFieldNum)
searchInt
- The search integerrule
- The rule for determining whether to introduce less than, greater than etc.customFieldNum
- Used to detect which custom field is being usedprotected java.lang.String getCustomSearchString(java.math.BigDecimal searchDec, int rule, int customFieldNum)
searchDec
- The search Big Decimalrule
- The rule for determining whether to introduce less than, greater than etc.customFieldNum
- Used to detect which custom field is being usedpublic java.lang.String escapeSearchString(java.lang.String searchString)
escapeSearchString
in interface SolrMgrIf
searchString
- the searchStringpublic java.lang.String getSolrUrl() throws java.lang.Exception
SolrMgrIf
getSolrUrl
in interface SolrMgrIf
java.lang.Exception
- an unexpected exceptionCopyright © 2018 DS Data Systems UK Ltd.