-
1. Re: SOLR Error - org.apache.commons.httpclient.NoHttpResponseException
davecordes Aug 19, 2015 6:53 PM (in response to davecordes)Anyone have any ideas?
-
2. Re: SOLR Error - org.apache.commons.httpclient.NoHttpResponseException
WolfShade Aug 20, 2015 6:24 AM (in response to davecordes)Intermittent errors are much more difficult to troubleshoot. But no one can help unless you provide some of your code (specifically the line where the error is occurring, and the surrounding lines.) It could be something very simple.
V/r,
^_^
-
3. Re: SOLR Error - org.apache.commons.httpclient.NoHttpResponseException
WolfShade Aug 20, 2015 6:28 AM (in response to davecordes)I did some Googling (I can't believe that is a VERB, now) and found some things that I hope will help.
http://hc.apache.org/httpclient-3.x/exception-handling.html
http://stackoverflow.com/questions/10558791/apache-httpclient-interim-error-nohttpresponse exception
HTH,
^_^
-
4. Re: SOLR Error - org.apache.commons.httpclient.NoHttpResponseException
davecordes Aug 20, 2015 7:59 AM (in response to WolfShade)No problem. Here is the code that runs. Basically what happens is I prepare the criteria for SOLR in one fashion, and if there are no results, relax the rules a bit and run a second search. If there are still no results, I run a third query with cfquery to try and get some results for the customer. The error can occur on any of the cfsearch lines below but they seem to occur more on the first getNavigations one.
<!--- Set search criteria --->
<cfset SearchCriteria = Trim(REReplaceNoCase(URL.criteria,"[^a-zA-Z0-9_ ]","","ALL"))>
<cfset SearchCriteria = REReplaceNoCase(SearchCriteria," AND "," ","ALL")><!--- Replace AND operator with a single space --->
<cfset SearchCriteria = REReplaceNoCase(SearchCriteria," OR "," ","ALL")><!--- Replace OR operator with a single space --->
<cfset SearchCriteria = REReplaceNoCase(SearchCriteria," NOT "," ","ALL")><!--- Replace NOT operator with a single space --->
<cfset SearchCriteria = REReplaceNoCase(SearchCriteria,"\s+"," ","ALL")><!--- Replace any number of spaces with a single space --->
<cfif Len(Trim(SearchCriteria))>
<!--- Set search criteria for solr --->
<cfset SearchCriteriaForSolr = "">
<cfloop index="i" list="#SearchCriteria#" delimiters=" ">
<cfset SearchCriteriaForSolr = SearchCriteriaForSolr & "+#i# ">
</cfloop>
<!--- Get products --->
<cfsearch name="getProducts" collection="product" criteria="#Trim(SearchCriteriaForSolr)#">
<cfif NOT getProducts.RecordCount>
<!--- Set search criteria for solr --->
<cfset SearchCriteriaForSolr = "">
<cfset ThisRow = 1>
<cfloop index="i" list="#SearchCriteria#" delimiters=" ">
<cfif ThisRow EQ 1>
<cfset SearchCriteriaForSolr = SearchCriteriaForSolr & "+#i# ">
<cfelse>
<cfset SearchCriteriaForSolr = SearchCriteriaForSolr & "#i# ">
</cfif>
<cfset ThisRow = ThisRow + 1>
</cfloop>
<!--- Get products --->
<cfsearch name="getProducts" collection="product" criteria="#SearchCriteriaForSolr#">
<cfif NOT getProducts.RecordCount>
<!--- Run a third query here with a LIKE statement --->
</cfif>
</cfif>
<!--- Get navigations --->
<cfsearch name="getNavigations" collection="navigation" criteria="#SearchCriteriaForSolr#">
<cfif NOT getNavigations.RecordCount>
<!--- Set search criteria for solr --->
<cfset SearchCriteriaForSolr = "">
<cfset ThisRow = 1>
<cfloop index="i" list="#SearchCriteria#" delimiters=" ">
<cfif ThisRow EQ 1>
<cfset SearchCriteriaForSolr = SearchCriteriaForSolr & "+#i# ">
<cfelse>
<cfset SearchCriteriaForSolr = SearchCriteriaForSolr & "#i# ">
</cfif>
<cfset ThisRow = ThisRow + 1>
</cfloop>
<!--- Get navigations --->
<cfsearch name="getNavigations" collection="navigation" criteria="#SearchCriteriaForSolr#">
<cfif NOT getNavigations.RecordCount>
<!--- Run a third query here with a LIKE statement --->
</cfif>
</cfif>
<cfelse>
<cfset getProducts.RecordCount = 0>
<cfset getNavigations.RecordCount = 0>
</cfif>
-
5. Re: SOLR Error - org.apache.commons.httpclient.NoHttpResponseException
WolfShade Aug 26, 2015 7:48 AM (in response to davecordes)Well, all your code seems to be fine, although I personally wouldn't add a '+' to the beginning of every word (Solr is good for phrase searches, too.) Plus, I think you could use RegEx to do that instead of looping. But, I digress (and boy is that painful - ba dum bump tssss!)
If the issue is intermittent, then I think that the SO link I offered in my earlier post might contain a solution. It's also possible that CF server, itself, is to blame (sometimes it seems like it takes a long time for certain page loads/refreshes to complete.)
V/r,
^_^