mysql搜索结果的问题不正确

时间:2015-10-24 10:17:45

标签: mysql

我的网站上的SQL查询返回的结果存在一些严重问题。 我有一个型号为DC250的特定产品,但如果您搜索DC250,实际产品不会在结果中首先显示,而是在第26位显示。鉴于此型号与搜索结果完全匹配,为什么它应该到目前为止呢?

以下是运行的SQL查询。

 SELECT DISTINCT p.products_model,  p.products_id, pd.products_name,
 IF( pd.products_name LIKE "dc250", 40, IF( pd.products_name LIKE "dc250%", 20, 0 )
 + IF( MATCH(pd.products_name, pd.products_description) AGAINST("dc250 dc250s"),
 MATCH(pd.products_name, pd.products_description) AGAINST("dc250 dc250s") * 40, 0) )
 + IF( MATCH(m.manufacturers_name) AGAINST("dc250 dc250s"), MATCH(m.manufacturers_name) AGAINST("dc250 dc250s") * 0, 0 )
 + IF( MATCH(p.products_model) AGAINST("dc250 dc250s"), MATCH(p.products_model) AGAINST("dc250 dc250s") * 20, 0)
 + IF( MATCH(mtpd.metatags_keywords, mtpd.metatags_description) AGAINST("dc250 dc250s"),
 MATCH(mtpd.metatags_keywords, mtpd.metatags_description) AGAINST("dc250 dc250s")* 30, 0)
 + (pd.products_viewed / 3475.6985) as weight FROM (products p LEFT JOIN manufacturers m
 USING(manufacturers_id), products_description pd, categories c, products_to_categories p2c )         
 LEFT JOIN meta_tags_products_description mtpd ON mtpd.products_id= p2c.products_id              
 AND mtpd.language_id = 1 WHERE (p.products_status = 1 AND p.products_id = pd.products_id                
 AND pd.language_id = 1 AND p.products_id = p2c.products_id                
 AND p2c.categories_id = c.categories_id  AND (
 MATCH(pd.products_name, pd.products_description) 
 AGAINST("dc250* dc250s*" IN BOOLEAN MODE)
 OR MATCH(p.products_model) AGAINST("dc250* dc250s*" IN BOOLEAN MODE)             
 OR MATCH(m.manufacturers_name) AGAINST("dc250* dc250s*" IN BOOLEAN MODE)             
 OR MATCH(mtpd.metatags_keywords, mtpd.metatags_description) 
 AGAINST("dc250* dc250s*" IN BOOLEAN MODE))) 
 order by p.products_model

0 个答案:

没有答案