sinoland Posted September 9, 2010 Share Posted September 9, 2010 Hello,Product names in some languages, e.g. Chinese language, are often formed by two or more words (without space). For proper display of search results, we need substring search support.After studying some threads, we found a possible solution as described in the next post. Thank you.Regards,Mr. Tsang Link to comment Share on other sites More sharing options...
sinoland Posted September 10, 2010 Author Share Posted September 10, 2010 Found a solution but not sure whether it is complete or not.Replace classes/Search.php lines 155 to 158 AND sw.word LIKE '.($word[0] == '-' ? ' \''.pSQL(Tools::substr($word, 1, PS_SEARCH_MAX_WORD_LENGTH)).'%\'' : '\''.pSQL(Tools::substr($word, 0, PS_SEARCH_MAX_WORD_LENGTH)).'%\'').' ) '; if ($word[0] != '-') $scoreArray[] = 'sw.word LIKE \''.pSQL(Tools::substr($word, 0, PS_SEARCH_MAX_WORD_LENGTH)).'%\''; with the following AND sw.word LIKE '.($word[0] == '-' ? ' \''.'%'.pSQL(Tools::substr($word, 1, PS_SEARCH_MAX_WORD_LENGTH)).'%\'' : '\''.'%'.pSQL(Tools::substr($word, 0, PS_SEARCH_MAX_WORD_LENGTH)).'%\'').' ) '; if ($word[0] != '-') $scoreArray[] = 'sw.word LIKE \''.'%'.pSQL(Tools::substr($word, 0, PS_SEARCH_MAX_WORD_LENGTH)).'%\''; Basically, the replacement adds .'%' right before .pSQLNow, if you search for 'book', MacBook would be listed. Link to comment Share on other sites More sharing options...
ciceron5978 Posted October 3, 2010 Share Posted October 3, 2010 Sorry but it doesn't work !! It is working for you ? Link to comment Share on other sites More sharing options...
Jubri Posted October 6, 2010 Share Posted October 6, 2010 Me too, doesn't workThis Freeze MySQL: SELECT DISTINCT cp.`id_product` FROM `ps_category_group` cg INNER JOIN `ps_category_product` cp ON cp.`id_category` = cg.`id_category` INNER JOIN `ps_category` c ON cp.`id_category` = c.`id_category` INNER JOIN `ps_product` p ON cp.`id_product` = p.`id_product` WHERE c.`active` = 1 AND p.`active` = 1 AND cg.`id_group` = 1 AND p.id_product IN ( SELECT id_product FROM ps_search_word sw LEFT JOIN ps_search_index si ON sw.id_word = si.id_word WHERE sw.id_lang = 3 AND sw.word LIKE '% F4580%' ) Space after % not exists, i can't write it without space at this forumThis Works OK: SELECT DISTINCT cp.`id_product` FROM `ps_category_group` cg INNER JOIN `ps_category_product` cp ON cp.`id_category` = cg.`id_category` INNER JOIN `ps_category` c ON cp.`id_category` = c.`id_category` INNER JOIN `ps_product` p ON cp.`id_product` = p.`id_product` WHERE c.`active` = 1 AND p.`active` = 1 AND cg.`id_group` = 1 AND p.id_product IN ( SELECT id_product FROM ps_search_word sw LEFT JOIN ps_search_index si ON sw.id_word = si.id_word WHERE sw.id_lang = 3 AND sw.word LIKE 'F4580%' ) It's seems be a loop a database level...'SubQuery', works fine individually at two examples.Any suggestion??Thanks Link to comment Share on other sites More sharing options...
Jubri Posted October 6, 2010 Share Posted October 6, 2010 MySQL version: 5.1.50-communityIt's seems a MySQL bug...http://bugs.mysql.com/bug.php?id=35042 ...yes, the subquery is re-evaluated every time because it is made correlated byIN->EXISTS transformation (for details seehttp://en.oreilly.com/mysql2008/public/asset/attachment/2128, slide #5 and around).... Link to comment Share on other sites More sharing options...
ciceron5978 Posted October 6, 2010 Share Posted October 6, 2010 so finally do we have a solution ? Link to comment Share on other sites More sharing options...
Vaidas Posted October 10, 2010 Share Posted October 10, 2010 I have the same bug. When there is empty space between word, search didn't work corectly. Have any ideas? Link to comment Share on other sites More sharing options...
faDdy Posted December 3, 2013 Share Posted December 3, 2013 I have the same problem ... anyone ? Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now