PDA

View Full Version : Search: too many results!!


cathobby
July 11th, 2003, 11:32 AM
How can I set up my search to only look for exact matches??
When a search is done, even for something very especific, it returns more that 5,000 results!!
Help!!!

cathobby
July 24th, 2003, 01:28 PM
I really need some help on this!
I just searched for something and got 18K results!
This should not be happening.

Jamie
July 24th, 2003, 03:49 PM
Hi,

The simple search on the homepage checks for any of the words you enter. To make it search for an exact phrase, change the template file "search_simple.php" as follows:

change:
<input type="hidden" name="search_type" value="any"> to:
<input type="hidden" name="search_type" value="exact">

I did a regular search for "Accurail 40" on your site, and got 6535 results. I then used the advanced search, set it to "exact", and it returned 23 matches.

Thanks,
Jamie

cathobby
July 25th, 2003, 05:41 PM
Ok, that is better but it is still returning too many results, from what I can tell this is because it is searching through the product text, which in my case is technical information about the product and mentions other related products.
Is there a way to make the search NOT search through that?

Jamie
July 25th, 2003, 05:56 PM
There should be an easier way to do this, but there isn't. Here is how (and be careful!):

Backup, then open file "squirrelcart/search_simple.php" in an editor. You should see this code:

<?
if (!$in_admin_section) {
$query_table="Products";
$query_mode = "simple";
$qry_fields[] = "Name";
$qry_fields[] = "Description";
$qry_fields[] = "Keywords";
$qry_fields[] = "Category";
}
$where = record_search($query_mode,$query_table,$qry_fields ,$search_template);
?>

Each line that starts with "$qry_fields[]" is what controls the fields that the search function will query. If you want to limit what fields are searched, remark out the fields you don't want to search by preceding them with:
//
Like in this example, which keeps the Description field from being queried:
<?
if (!$in_admin_section) {
$query_table="Products";
$query_mode = "simple";
$qry_fields[] = "Name";
// $qry_fields[] = "Description";
$qry_fields[] = "Keywords";
$qry_fields[] = "Category";
}
$where = record_search($query_mode,$query_table,$qry_fields ,$search_template);
?>

-Jamie

gtroll
July 25th, 2003, 06:16 PM
Is it possible to have a weighted results? i.e. to have the search results bring up the closest exact match first then the other matches
for example search on "red tshirt" have the red tshirt be the first match and the other tshirts after that?

Jamie
July 26th, 2003, 12:14 AM
Good idea! Can you please create a new post in requests for this?

Thanks,
Jamie

lzgsch
September 17th, 2006, 09:50 PM
How to limit what fields are searched in newer version (2.1.1)? Thank you for your help in advance!