Forgot password?
 Create new account
View 331|Reply 2

搜索_搜索

[Copy link]

3146

Threads

8493

Posts

610K

Credits

Credits
66158
QQ

Show all posts

hbghlyj Posted at 2022-8-2 23:36:31 |Read mode
Last edited by hbghlyj at 2022-12-23 00:25:00关键字中可使用通配符 "*"
匹配多个关键字全部,可用空格或 "AND" 连接。如 win32 AND unix
匹配多个关键字其中部分,可用 "|" 或 "OR" 连接。如 win32 OR unix
用户名中可使用通配符 "*",如 *user*

关于搜索选项:
  • 按作者:此处可以填写发帖作者全名,也可以使用通配符"*",如填写"a*",就可以搜索到所有以a开头的用户发的帖子。
  • 搜索方式:有“标题搜索”、“全文搜索”两种方式。
  • 搜索时间:关于搜索时间的选择是个组合方式:全部时间/1天/2天/1周/1个月/3个月/6个月/1年 + 以内/以前
  • 排序类型:关于排序类型的选择也是个组合方式:回复时间/发布时间/回复数量/浏览次数 + 按升序排列/按降序排列
  • 搜索范围:选择要进行搜索的版块,可以按住 Ctrl 多选。

/source/module/search/search_forum.php
Discuz! X3.4 使用教程文档 » 1. 全局 » 1.14. 搜索设置
Discuz!6.0 多种搜索方式详解
[Discuz7.2]让高级搜索更全面
Discuz! X3 sphinx/coreseek全文搜索安装配置实战
DiscuzX内置的搜索功能实现。
如果搜索的是新内容,从来没有被人搜索过的内容。则DZ进行一次搜索。然后把搜索结果的id序列和一些其他信息储存在
pre_common_searchindex 表格中。
下次再有人查询这个关键字的时候。首先会查询 pre_common_searchindex 表,如果有记录的话。则从表中取到结果的id序列,直接select in来取这些记录。
当然pre_common_searchindex中的记录是有时效的。过期无效。系统中每天晚上有计划任务清除这个表。
Discuz搜索模块解析
检索完成后,discuz会将搜索结果保存到common_searchindex表中作为一次搜索记录,ids那一列即为匹配帖子的tid列表:
  1. $searchid = C::t('common_searchindex')->insert(array(
  2.                                 'srchmod' => $srchmod,
  3.                                 'keywords' => $keywords,
  4.                                 'searchstring' => $searchstring,
  5.                                 'useip' => $_G['clientip'],
  6.                                 'uid' => $_G['uid'],
  7.                                 'dateline' => $_G['timestamp'],
  8.                                 'expiration' => $expiration,
  9.                                 'num' => $num,
  10.                                 'ids' => $ids
  11.                         ), true);
Copy the Code

根据ids获取到帖子的信息后,对标题进行高亮操作,再返回给用户:
  1. foreach(C::t('forum_thread')->fetch_all_by_tid_fid_displayorder(explode(',',$index['ids']), null, 0, $orderby, $start_limit, $_G['tpp'], '>=', $ascdesc) as $thread) {
  2.     $thread['subject'] = bat_highlight($thread['subject'], $keyword);
  3.     $thread['realtid'] = $thread['isgroup'] == 1 ? $thread['closed'] : $thread['tid'];
  4.     $threadlist[$thread['tid']] = procthread($thread, 'dt');
  5.     $posttables[$thread['posttableid']][] = $thread['tid'];
  6. }
Copy the Code

最多只能显示500个结果
搜索通配符*会匹配一切帖子,显示
结果: 找到 “ ” 相关内容 500 个
image-147[1].png
搜索加号+也会匹配一切帖子,也显示
结果: 找到 “ ” 相关内容 500 个
Screenshot 2022-12-22 at 23-23-57 关于搜索 - 站务管理 - 悠闲数学娱乐论坛(第3版) .png

3146

Threads

8493

Posts

610K

Credits

Credits
66158
QQ

Show all posts

 Author| hbghlyj Posted at 2022-8-3 11:33:29

and or

搜索"Radicals and"和"and units"都可以高亮and
而搜索"Radicals and units"就会把and去掉变成"Radicals units"
我理解的是这样: 大写的AND是保留关键字, 而小写的and过于常用, 筛选效果不好, 所以在搜索中提前去除了.
小写的or被没有去除, 可以正常匹配到:
QQ图片20220803044150.png

3146

Threads

8493

Posts

610K

Credits

Credits
66158
QQ

Show all posts

 Author| hbghlyj Posted at 2022-8-3 11:44:13

异常情况

搜索1+1变成了1 1
搜索1&1变成了1 amp;1
搜索1_1变成了1\_1
搜索1<1变成了1 lt;1
搜索1>1变成了1 gt;1
搜索1"1变成了1 quot;1
搜索1'1变成了您当前的访问请求当中含有非法字符,已经被系统拒绝

标题为"搜索_搜索", 则"搜索_搜索"可以搜索到, 标题中的关键词却未被高亮
QQ图片20220803044150.png
如果加上一个空格, 搜索"搜索 _搜索", 则可以搜索到, 且标题中的关键词被高亮
QQ图片20220803044150.png

手机版Mobile version|Leisure Math Forum

2025-4-20 22:04 GMT+8

Powered by Discuz!

× Quick Reply To Top Return to the list