Jump to content

Search not working right


Recommended Posts

Hello, I am having some issues with my search, at least its not working the way I would like.

We have a product The Torch Is Passed, we have it listed as Torch Is Passed, The

now when i search for Is Passed I get no results but if i search for Passed i get results and the first one listed is in fact Torch Is Passed, The, Im also having issues with when you search for the normal title The Torch Is Passed I get no results, yet The is in the blocked and looks like punctuation is removed (looking in classes/search.php) so I would assume its searching for Torch Is Passed.

So in all, the search is way to strict

Quick Results

Title Torch Is Passed, The

No results found for your search "The Torch Is Passed"
No results found for your search "Torch Is Passed, The"
No results found for your search "Torch Is Passed"
No results found for your search "Is Passed"
Passed - 3 results

so far the only ways I can search for this product is searching Passed or as I type the Ajax Search finds it and works if i select it.


I am also wanting to be able to search by the reference # or some other field because most people want to search by product number. Is there maybe a better search module?


Thank in advance
Don G.

Link to comment
Share on other sites

Just noticed that the demo site I can search for "nano" and i get 2 results

iPod Nano
Housse portefeuille en cuir...

So it seems like it should be a little better then what mine is doing.

Also I'm running Version 1.2.5.0 - 0.071s

Link to comment
Share on other sites

I was looking through the search_words table and i see its indexed the words

8120|1|torch
3230|1|passed
8474|1|passed,

and in search_index

9562|8120|6
9562|8474|6
... bunch of other rows for words in the description

Link to comment
Share on other sites

OK if you want the search to index "the" you will have to do 2 things:

go to back office under Preferences tab --> Search

1. remove "the" from the blacklisted words
2. set Minimum word length option to "2"

Then click on rebuild entire index, this should do it !!

Link to comment
Share on other sites

I really need some help here, as it is, the site is pretty much un-searchable and most of our customers would rather search then browse.

I took some screen shots today, cause its just really acting strange.

Also, is there a way to use the Admin search code for the from end? because the admin search works perfect, can do partial title searches, and even supp. Reference search (thats what most people want to search by)

Thanks again
Don G.

21534_LbvZAQfHmu6caclk5CDc_t

21535_a2ma4lTHygAOLXiuAoO7_t

21536_7lwH3mkXUwimJqJDQr5K_t

Link to comment
Share on other sites

Well I kinda fixed it by stealing the SQL from the admin search (Product::searchByName())

Not sure what kind of issues this could cause so fixing the original search Query would be nice

just changed the $queryResults SQl to whats below and added the sanitize on $expr

Edit should be around line 195 in classes/Search.php (did changes before noticing original line number)

       $query = Search::sanitize($expr, $id_lang);
       $queryResults = '
       SELECT SQL_CALC_FOUND_ROWS p.*, pl.`description`, pl.`available_now`, pl.`available_later`, pl.`link_rewrite`, pl.`name`,
       t.`rate`, i.`id_image`, il.`legend`, m.`name` AS manufacturer_name
       '.$score.'
       FROM `'._DB_PREFIX_.'category_product` cp
       LEFT JOIN `'._DB_PREFIX_.'product` p ON p.`id_product` = cp.`id_product`
       LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON (p.`id_product` = pl.`id_product` AND pl.`id_lang` = '.intval($id_lang).')
       LEFT JOIN `'._DB_PREFIX_.'tax` t ON t.`id_tax` = p.`id_tax`
       LEFT JOIN `'._DB_PREFIX_.'tax_lang` tl ON (t.`id_tax` = tl.`id_tax` AND tl.`id_lang` = '.intval($id_lang).')
       LEFT JOIN `'._DB_PREFIX_.'manufacturer` m ON m.`id_manufacturer` = p.`id_manufacturer`
       LEFT JOIN `'._DB_PREFIX_.'image` i ON (i.`id_product` = p.`id_product`) AND i.`cover` = 1
       LEFT JOIN `'._DB_PREFIX_.'image_lang` il ON (i.`id_image` = il.`id_image` AND il.`id_lang` = '.intval($id_lang).')
       WHERE pl.`name` LIKE \'%'.pSQL($query).'%\' OR p.`reference` LIKE \'%'.pSQL($query).'%\' OR p.`supplier_reference` LIKE \'%'.pSQL($query).'%\'
       AND p.active = 1
       GROUP BY `id_product`
       '.($orderBy ? 'ORDER BY  '.$orderBy : '').($orderWay ? ' '.$orderWay : '').'
       LIMIT '.intval(($pageNumber - 1) * $pageSize).','.intval($pageSize);

Link to comment
Share on other sites

  • 1 month later...

i want ask about ajax serach and search in BO. when i put numer in BO search E1234 show my produkt with name/reference e1234 when i put 1234 result is the same ( show me product E1234) . when im in FO and put 1234 in ajax serach dont have result with this product who have name/reference E1234.

is it a problem with regular expressions??

somebody repair and have idea why in BO working good but in FO not :

Link to comment
Share on other sites

  • 1 year later...
Well I kinda fixed it by stealing the SQL from the admin search (Product::searchByName())

Not sure what kind of issues this could cause so fixing the original search Query would be nice

just changed the $queryResults SQl to whats below and added the sanitize on $expr

Edit should be around line 195 in classes/Search.php (did changes before noticing original line number)
       $query = Search::sanitize($expr, $id_lang);
       $queryResults = '
       SELECT SQL_CALC_FOUND_ROWS p.*, pl.`description`, pl.`available_now`, pl.`available_later`, pl.`link_rewrite`, pl.`name`,
       t.`rate`, i.`id_image`, il.`legend`, m.`name` AS manufacturer_name
       '.$score.'
       FROM `'._DB_PREFIX_.'category_product` cp
       LEFT JOIN `'._DB_PREFIX_.'product` p ON p.`id_product` = cp.`id_product`
       LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON (p.`id_product` = pl.`id_product` AND pl.`id_lang` = '.intval($id_lang).')
       LEFT JOIN `'._DB_PREFIX_.'tax` t ON t.`id_tax` = p.`id_tax`
       LEFT JOIN `'._DB_PREFIX_.'tax_lang` tl ON (t.`id_tax` = tl.`id_tax` AND tl.`id_lang` = '.intval($id_lang).')
       LEFT JOIN `'._DB_PREFIX_.'manufacturer` m ON m.`id_manufacturer` = p.`id_manufacturer`
       LEFT JOIN `'._DB_PREFIX_.'image` i ON (i.`id_product` = p.`id_product`) AND i.`cover` = 1
       LEFT JOIN `'._DB_PREFIX_.'image_lang` il ON (i.`id_image` = il.`id_image` AND il.`id_lang` = '.intval($id_lang).')
       WHERE pl.`name` LIKE \'%'.pSQL($query).'%\' OR p.`reference` LIKE \'%'.pSQL($query).'%\' OR p.`supplier_reference` LIKE \'%'.pSQL($query).'%\'
       AND p.active = 1
       GROUP BY `id_product`
       '.($orderBy ? 'ORDER BY  '.$orderBy : '').($orderWay ? ' '.$orderWay : '').'
       LIMIT '.intval(($pageNumber - 1) * $pageSize).','.intval($pageSize);



Thx Don G. it works like a charme, i will try to fix the org code now, to see what happend.
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...