Home > Backend Development > PHP Tutorial > 做搜索查询的时候 如何拆分词

做搜索查询的时候 如何拆分词

WBOY
Release: 2016-06-13 12:14:22
Original
2375 people have browsed it

做搜索查询的时候 怎么拆分词?
比如说 
商品标题
字段title
秋冬新款大码女装宽松毛衣外套女开衫加厚中长款羊毛
商品评论
字段content
秋冬季室内穿着舒适,出外搭配棉羽背心也时尚应景。A字型裙摆式款型,可以遮挡腰腹赘肉。肩部承重力在织造设计方面值得升级改进。袖笼围度窄瘦,袖长偏短,用料与正身之阔绰相比,显寒碜。由此内里只能搭配无袖或薄型衬衫。本人159cm,135g,103cm胸围,39cm肩宽,35cm臂围,供参考。十分担心缩水率,唯恐宝贝是“一水衣”。 


搜索 大码 羊毛 外套

搜索 大码 羊毛 舒适 款型

这样怎么实现呢 应该是什么样思路呢 我开始想的是取出关键词 一个词一个词的'%'.$wd.'%'?那样也实现不了 几个词同时出现的时候



------解决思路----------------------
MySQL 提供了正则表达式检索,为何不用一下呢?

$word = '大码 羊毛 外套';<br />$word = preg_replace('/\s+/', '<br><font color='#FF8000'>------解决思路----------------------</font><br>' ,trim($word));<br />$sql = "select * from tbl_name where concat(title,content) REGEXP '$word'";<br />
Copy after login

如果条件允许的话,使用第三方的全文检索驱动,效率要高很多

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template