No search results found
I'm trying to create a search for products and the results are coming back with no results found. Can someone let me know what I'm doing wrong? Thanks! search-results.php
<?php
$query = perch_get('q');
perch_content_search($query, array(
'template'=>'search-result.html'
));
?>
search result.html
<perch:before>
<h1>Search results for “<perch:search id="search_key" />”</h1>
<perch:if exists="paging">
<p><perch:search id="total" /> results</p>
</perch:if>
<ul>
</perch:before>
<li class="<perch:search id="perch_item_odd" />">
<h2><a href="<perch:search id="result_url" />"><perch:search id="result_title" /></a></h2>
<perch:if exists="result_excerpt"><p class="excerpt">…<perch:search id="result_excerpt" encode="false" />…</p></perch:if>
<p><a href="<perch:search id="result_url" />">
<perch:if exists="result_pageNavText">
<perch:search id="result_pageNavText" />
<perch:else />
<perch:search id="result_url" />
</perch:if>
</a></p>
</li>
<perch:after>
</ul>
<perch:if exists="paging">
<div class="paging">
Page <perch:search id="current_page" /> of <perch:search id="number_of_pages" />
<perch:if exists="not_first_page">
<a href="<perch:search id="prev_url" encode="false" />">Previous</a>
</perch:if>
<perch:if exists="not_last_page">
<a href="<perch:search id="next_url" encode="false" />">Next</a>
</perch:if>
</div>
</perch:if>
</perch:after>
<perch:noresults>
<perch:if exists="search_key">
<h1>Search results for “<perch:search id="search_key" />”</h1>
<perch:else />
<h1>Search</h1>
</perch:if>
<perch:if exists="search_key">
<p>Sorry, there are no results for “<perch:search id="search_key" />”.</p>
</perch:if>
</perch:noresults>
search-bar.php
<?php perch_search_form(); ?>
search-form.html
<div class="exp-search"><perch:form id="search" method="get" action="search-results.php">
<div>
<perch:input type="search" id="q" class="exp-search-input" placeholder="Search"/>
<perch:input type="submit" value="Go" class="exp-search-submit"/>
</div>
</perch:form>
</div>
How many products are you searching?
I want to be able to search throughout the whole library of products. At the moment I've only got about ten products outputted but there will be a few hundred
It could be that you've not got enough content in there yet to make the search effective.
So if I try adding more products it should work? Thanks, I'll try that!
Okay, so I've added more products on there, so there are about 100 product on there and it's still not working
If you turn on debug, what does it output?
this is from the search of 'mob' (there's a product called mob cap)
Do you have products that include the word 'mob' ?
It's too short a search string for the more advanced algorithm, and the basic search will only match if that's a word that is used.
Yes, there is a product called Mob Cap. I have tried Mob Cap and still nothing
Have you fixed the error you're getting about the use of
RAND
?I have yes
Ok, what does the debug say now?
It's certainly finding no matches. Have you tried other search terms?
Yes, here is the debug for another search
You're still getting errors there, and you're still a few versions behind. You'll want to address those to make sure you're in the best position to troubleshoot.
What are the errors?
Now that's fixed,
Ok, great. Let me know how things are looking once you're on the current version.