| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1844 人关注过本帖
标题:[讨论]如何实现象google百度那样的模糊查询?
取消只看楼主 加入收藏
肖走
Rank: 1
等 级:新手上路
帖 子:85
专家分:0
注 册:2005-9-26
收藏
 问题点数:0 回复次数:8 
[讨论]如何实现象google百度那样的模糊查询?
如题,想要实现输入“关键字+空格+关键字”的查询方式,该如何实现呢?是不是先判断有无空白字,然后再用Replace()实现呢?
搜索更多相关主题的帖子: google 百度 模糊 查询 
2006-06-12 10:16
肖走
Rank: 1
等 级:新手上路
帖 子:85
专家分:0
注 册:2005-9-26
收藏
得分:0 
以下是引用islet在2006-6-12 10:27:04的发言:
key=replace(replace(replace(replace(replace(replace(replace(request(keywords)," ","")," ","")," ","")," ","")," ","")," ","")," ","")
words=split(key," ")
sql="select * from table where 字段 like '%"&key&"%'"
for i= 0 to ubound(words)-1
sql=sql&" or 字段 like '%"&words(i)&"%'"
next
rs.open sql,conn,1,1

麻烦解释一下吧,谢谢了!有点看晕了


2006-06-12 10:39
肖走
Rank: 1
等 级:新手上路
帖 子:85
专家分:0
注 册:2005-9-26
收藏
得分:0 

哦,明白了!


2006-06-12 11:09
肖走
Rank: 1
等 级:新手上路
帖 子:85
专家分:0
注 册:2005-9-26
收藏
得分:0 
以下是引用hangxj在2006-6-12 10:52:25的发言:
split不是方便很多?

说说看嘛,大家讨论讨论!


2006-06-12 11:23
肖走
Rank: 1
等 级:新手上路
帖 子:85
专家分:0
注 册:2005-9-26
收藏
得分:0 
以下是引用islet在2006-6-12 10:51:26的发言:
key=replace(replace(replace(replace(replace(replace(replace(request(keywords)," ","")," ","")," ","")," ","")," ","")," ","")," ","") '尽可能把多余的空格替换掉
words=split(key," ") '把输入的关键字按空格断成书组
sql="select * from table where 字段 like '%"&key&"%'" '先给一个条件 什么条件都行
for i= 0 to ubound(words)-1 '把数组循环取出
sql=sql&" or 字段 like '%"&words(i)&"%'"
next
rs.open sql,conn,1,1

我觉得应该是这样的:
key=replace(replace(replace(replace(replace(replace(replace(request(keywords)," ","")," ","")," ","")," ","")," ","")," ","")," ","") '尽可能把多余的空格替换掉
words=split(request(keywords)," ") '把输入的关键字按空格断成书组
sql="select * from table where 字段 like '%"&key&"%'" '先给一个条件 什么条件都行
for i= 0 to ubound(words) '把数组循环取出
sql=sql&" or 字段 like '%"&words(i)&"%'"
next
rs.open sql,conn,1,1

这样就可以了!


2006-06-13 10:21
肖走
Rank: 1
等 级:新手上路
帖 子:85
专家分:0
注 册:2005-9-26
收藏
得分:0 
以下是引用islet在2006-6-13 10:47:09的发言:
words=split(request(keywords)," ")
人家输入:手机 飞利浦
就不好了

这样改两个空格换成一个
key=replace(replace(replace(replace(replace(replace(replace(request(keywords)," "," ")," "," ")," "," ")," "," ")," "," ")," "," ")," "," ") '尽可能把多余的空格替换掉
words=split(key," ")

如果人家输入:手机 飞利浦(中间只有一个空格),那key就没有空格了,key="手机飞利浦",还怎么分割啊?!


2006-06-13 11:10
肖走
Rank: 1
等 级:新手上路
帖 子:85
专家分:0
注 册:2005-9-26
收藏
得分:0 
哦,没看清楚,后来换成两个换一个了啊!这样就更好了!

2006-06-13 11:19
肖走
Rank: 1
等 级:新手上路
帖 子:85
专家分:0
注 册:2005-9-26
收藏
得分:0 
现在发现这样查找不是很好,不是很精确,有些关键字在别的记录里也有,就会找出很多没用的记录来,增加了查找复杂度,降低了命中率!

[此贴子已经被作者于2006-6-13 11:32:48编辑过]



2006-06-13 11:27
肖走
Rank: 1
等 级:新手上路
帖 子:85
专家分:0
注 册:2005-9-26
收藏
得分:0 
看来还是得有词库才行啊!

2006-06-13 11:34
快速回复:[讨论]如何实现象google百度那样的模糊查询?
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.059160 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved