Low Search SQL Error
I am not sure where went wrong. I tried to search with some keyword, "Hancock," "Crafty" the first time I used these words, it worked fine. But the second time I searched with these words, it returned a SQL error page. Please see the screenshot.
Thanks,
Chris
Replies
chunkitdesign 22 Aug 2019 19:26
Another issue is that the second search with the same keyword will return no results in the log, but the search result page display all the entries.
chunkitdesign 22 Aug 2019 19:37
After I did a couple of testings, I am wondering if there is a time interval for each search. It seems like after a while those keywords can be searched again.
chunkitdesign 22 Aug 2019 19:43
It seems like if within the same minute i search with the same keyword it will return SQL errors.
chunkitdesign 22 Aug 2019 23:42
Here are what EE has found out. Thank you for your help.
Well- I see where it fails. It's because the query is coming back with results, but the cached session data says it has none.
Low 23 Aug 2019 07:46
The error is triggered by the native channel:entries tag (which is called by the low_search:results tag). Not sure why it would throw that error, tho.
What are your Low Search, EE and PHP versions? Also, can you share your low_search:form and :results template tags? You can use http://pastebin.com/ for large chunks of code.
chunkitdesign 23 Aug 2019 13:00
Hey Low,
the Low search code i have is simple.
<div class="sf-SearchForm" role="search">
<form class="searchForm hidden">
<div class="grid--base grid--1-col-max">
<div class="grid__component">
{exp:low_search:form required="keywords"}
<div class="search">
<label for="keywords" class="show-for-sr">
<span class="field-label">Search</span>
</label>
<input class="searchTerm" type="search" id="keywords" name="keywords" placeholder="Keywords. For example, Hancock">
<button type="submit" class="searchButton"><i class="icon-svg icon-svg--18px icon-svg--black"><svg><use xlink:href="#icon-search-filled"></use></svg></i><span class="show-for-sr">Search</span></button>
</div>
{/exp:low_search:form}
</div>
</div>
</form>
</div>
chunkitdesign 23 Aug 2019 13:03
What are your Low Search, EE and PHP versions?
LS: 6.2
EE: 5.2.6
Php: 7.1.12
chunkitdesign 23 Aug 2019 13:04
Search Results:
<div class="grid--base grid--2-col-2-1">
<div class="grid__component">
<h1>Search Results</h1>
{exp:low_search:results
query="{segment_3}"
status='{ch_status}'
keywords:lang="en"
keywords:inflect="yes"
limit="10"
}
{if count == 1}
<p>
Searched for <strong>{low_search_keywords}</strong>.
Search results: <strong>{absolute_results}</strong>
</p>
<ol class="sr-SearchResults_List">
{/if}
<li class="sr-SearchResults_ListItem">
<h3 class="sr-SearchResults_Title"><a href="{auto_path}">{title}</a></h3>
<p class="sr-SearchResults_Blurb">{low_search_excerpt}</p>
<p class="sr-SearchResults_Note">Found in <span class="sr-SearchResults_CollectionLabel"> {low_search_collection_label}</span>, with a relevancy of {low_search_score}</p>
</li>
{if count == total_results}</ol>{/if}
{paginate}
{current_page}/{total_pages} | {pagination_links}
{/paginate}
{if low_search_no_results}
<p>
No results for “{low_search_keywords}”.
{exp:low_search:suggestions keywords="{low_search_keywords}" keywords:lang="en" limit="2"}
{if suggestion_count == 1}Did you mean{/if}
<a href="{low_search:url keywords="{suggestion}"}">{suggestion}</a>{if suggestion_count != total_suggestions} or {if:else}?{/if}
{if no_suggestions}Check your spelling or try a different search term.{/if}
{/exp:low_search:suggestions}
</p>
{/if}
{/exp:low_search:results}
</div>
<div class="grid__component">
</div>
</div>
chunkitdesign 23 Aug 2019 13:15
More info.
In the screenshot, "hancock" returns 0, on the front end, it returns SQL errors.
"craft" also returns 0, on the front end, it list all 1150 entries of the site.
chunkitdesign 23 Aug 2019 13:18
and some keywords even trigger a redirect like this one:
mysite.com/search/results/index.php?/cp/channels/fields/edit/163&S=2f4f92cd217c284295f44dd29e803882
chunkitdesign 23 Aug 2019 13:22
If you need my site login please let me know. I really appreciate your help.
Low 23 Aug 2019 13:34
If the log says 0 results but you have results on the front-end, then something is preventing the log to update the number.
So I'll need to take a look myself. Please send SuperAdmin login credentials to hi at gotolow dot com if you can.
chunkitdesign 23 Aug 2019 13:55
another testing.
I searched the keyword, "Craft" three times
the first time and second time return proper result.
the third time it did not work and return a redirect link that cannot be found.
http://harthousetempsite.ca/search/results/index.php?/cp/channels/fields/edit/163&S=ef9737f801f6be4967506db3ad6e3f95
And then in the LS CP, it shows this error message
chunkitdesign 23 Aug 2019 16:02
Hi Low, Here is some other information you might be interested.
I cached the html-wrapper layout before. (not sure if it would trigger the error)
Just now, I also uninstalled the Low Search and reinstalled it.
And then disable caching for the layout.
chunkitdesign 25 Aug 2019 01:30
not sure if this log is helpful. thanks
Deprecated function full_tag() called in /chroot/home/harthous/harthousetempsite.ca/system/user/addons/low_search/mod.low_search.php on line 1920.
From template tag exp:low_search:results in search/results.
Deprecated since 4.0. Use ee('Variables/Parser')->getFullTag() instead.
Low 25 Aug 2019 08:51
Caching is somehow involved here. If I clear cache and reload the page, it works fine. If I disable caching globally, it works fine, too. As soon as caching is turned on, the error is triggered for some keywords, which is very odd to me (eg. searching for 'house' works every time). Note that submitting the form again will result in the same URL which throws the error when you reload it. So if you search for 'Hancock' once, then reload the page, it will display the error.
Looking at the debug output, it's very much looking like an issue outside of Low Search. The fact that it also works with caching disabled, confirms this. The weird redirect links again are testament to it being an issue outside of LS.
I suggest you check the server environment and/or ask EllisLab about this. The
ee()->session->cache['channel']['entry_ids']
is empty when it shouldn't be. Not sure why it would be empty (LS doesn't touch it) or why it displays that behaviour for only some of the URIs.The reason why the search log mentions 0 for the second time you search (when the error appears) is because of the error appearing; LS doesn't get to update that log record with the actual amount of search results, which it can only get to when it called the channel:entries tag from the low_search:results tag. Solve the sql error, and the log will be fine.
chunkitdesign 25 Aug 2019 19:35
Hi, Low,
Thanks so much for your help. I'll definitely pass it to EE.
But one thing you might be interested to test. You may enable to dynamic caching on your end and see if the search results display any error messages. I tested it and once I turn off the dynamic caching everything runs smoothly and no error displayed.
If so, LS has a conflict with EE dynamic caching
Low 26 Aug 2019 12:07
Ah right, EE's dynamic query caching is flakey. As per EE's docs:
If EE itself cannot be used reliably with this option turned on, then it could easily cause erratic behaviour in LS. Best to turn it off (and I'll look into adding a caveat to the LS docs mentioning this).