惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

W
WeLiveSecurity
T
The Exploit Database - CXSecurity.com
C
CXSECURITY Database RSS Feed - CXSecurity.com
S
Security @ Cisco Blogs
T
Threat Research - Cisco Blogs
TaoSecurity Blog
TaoSecurity Blog
Recent Commits to openclaw:main
Recent Commits to openclaw:main
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
腾讯CDC
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
T
The Blog of Author Tim Ferriss
Microsoft Azure Blog
Microsoft Azure Blog
罗磊的独立博客
F
Full Disclosure
博客园 - 【当耐特】
C
CERT Recently Published Vulnerability Notes
Engineering at Meta
Engineering at Meta
Application and Cybersecurity Blog
Application and Cybersecurity Blog
T
Threatpost
I
Intezer
V2EX - 技术
V2EX - 技术
H
Hackread – Cybersecurity News, Data Breaches, AI and More
The Hacker News
The Hacker News
小众软件
小众软件
Google DeepMind News
Google DeepMind News
T
Tailwind CSS Blog
D
Darknet – Hacking Tools, Hacker News & Cyber Security
B
Blog RSS Feed
Microsoft Security Blog
Microsoft Security Blog
N
News | PayPal Newsroom
MyScale Blog
MyScale Blog
AI
AI
Vercel News
Vercel News
Spread Privacy
Spread Privacy
美团技术团队
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
The GitHub Blog
The GitHub Blog
V
Vulnerabilities – Threatpost
Schneier on Security
Schneier on Security
Cyberwarzone
Cyberwarzone
G
GRAHAM CLULEY
Help Net Security
Help Net Security
Hacker News: Ask HN
Hacker News: Ask HN
Google DeepMind News
Google DeepMind News
MongoDB | Blog
MongoDB | Blog
L
LINUX DO - 热门话题
U
Unit 42
L
LangChain Blog
Recent Announcements
Recent Announcements

博客园 - 懒牛拉车

xxx tmp Thinkphp 3.2 Cookie丢失导致中英文混排 第一个python自动化实例 Nginx配置文件下载 每次用npm都很烦人 js 判断mac地址是否为组播地址 项目在本地时,css/js文件在浏览器刷新时,从(memory cache)读取,放服务器上就不会 模拟json_decode解析非法utf-8编码字符串 php socket 循环ping ip,显示能ping通的IP地址 thinkphp3.2.2 CheckLangBehavior.class中,使用session无效原因分析 Thikphp 3.2 session页面传递失败问题 火狐autocomplete="off"无效 testlink windows 安装笔记 宝塔面板部署thinkcmf问题 coreseek 測試用例 centos6 nginx 配置本地https访问 centos6 nginx安装好以后,添加拓展ssl centos6 php7 安装 memcache 和 memcached - 懒牛拉车 centos7 搭建 php7 + nginx (2) - 懒牛拉车 centos7 搭建 php7 + nginx (1)
coreseek 基与Sphinx 的全文索引
懒牛拉车 · 2019-12-06 · via 博客园 - 懒牛拉车

假设有两张那个表,分别为articles,article_photos两张表。搜索的时候,要匹配articles.title、articles.intro、article_photos.caption这三个字段。

  • PHP页面


header("content-type:text/html;charset=utf8");
include './sphinxapi.php'; //包含sphinxapi类
$sphinx = new SphinxClient(); //实例化
$sphinx->SetServer('localhost', 9312);//链接
$sphinx->SetLimits(0, 1000, 1000); //默认匹配20条记录。加上这行表示匹配1000条记录。(可用于分页)
$res = $sphinx->Query("暴动", "*");//查询的字段第二参数是你配置文件里面写得规则这里是*就会匹配所有规则

echo "<pre>";
print_r($res['matches']);

  • coreseek.conf 内容配置如下
#源定义
#mysql类只实现连接数据库
source mysql {
    type                    = mysql
    sql_host                = localhost
    sql_user                = root
    sql_pass                =
    sql_db                  = nextmgz_archive
    sql_port                = 3306
    sql_query_pre           = SET NAMES utf8

    # 命令行查询时,设置正确的字符集
    sql_query_info_pre      = SET NAMES utf8
}


# 继承mysql
source articles : mysql
{
    #sql_query第一列id需为整数
    #title、content作为字符串/文本字段,被全文索引
    sql_query                = SELECT art_id,title,intro FROM articles

    # 从SQL读取到的值必须为整数
    sql_attr_uint            = art_id

    # 从SQL读取到的值必须为整数,作为时间属性
    # sql_attr_timestamp        = date_added

    # 命令行查询时,从数据库读取原始数据信息
    sql_query_info          = SELECT * FROM articles WHERE art_id=$id
}

#index定义
index articles
{
    # 对应的source名称
    source           = articles
    #请修改为实际使用的绝对路径,例如:/usr/local/coreseek/var/
    path             = E:/__Work/coreseek-4.1-win32/var/data/articles
    docinfo          = extern
    mlock            = 0
    morphology       = none
    min_word_len     = 1
    html_strip       = 0

    #中文分词配置,详情请查看:http://www.coreseek.cn/products-install/coreseek_mmseg/
    #charset_dictpath = /usr/local/mmseg3/etc/ #BSD、Linux环境下设置,/符号结尾
    charset_dictpath    = E:/__Work/coreseek-4.1-win32/etc/ #Windows环境下设置,/符号结尾,最好给出绝对路径,例如:C:/usr/local/coreseek/etc/...
    charset_type        = zh_cn.utf-8
}

source article_photos : mysql
{
    sql_query               = SELECT art_id,caption FROM article_photos
    sql_attr_uint           = art_id
    sql_query_info       = SELECT * FROM article_photos WHERE art_id=$id
}

index article_photos
{
    source           = article_photos
    path              = E:/__Work/coreseek-4.1-win32/var/data/article_photos
    docinfo          = extern
    mlock            = 0
    morphology       = none
    min_word_len     = 1
    html_strip       = 0
    charset_dictpath = E:/__Work/coreseek-4.1-win32/etc/ #Windows环境下设置,/符号结尾,最好给出绝对路径,例如:C:/usr/local/coreseek/etc/...
    charset_type     = zh_cn.utf-8
}

#全局index定义
indexer
{
    mem_limit            = 128M
}

#searchd服务定义
searchd
{
    listen              = 9312
    read_timeout        = 5
    max_children        = 30
    max_matches         = 1000
    seamless_rotate     = 0
    preopen_indexes     = 0
    unlink_old          = 1
    pid_file            = E:/__Work/coreseek-4.1-win32/var/log/searchd_mysql.pid    #请修改为实际使用的绝对路径,例如:/usr/local/coreseek/var/...
    log                 = E:/__Work/coreseek-4.1-win32/var/log/searchd_mysql.log    #请修改为实际使用的绝对路径,例如:/usr/local/coreseek/var/...
    query_log           = E:/__Work/coreseek-4.1-win32/var/log/query_mysql.log      #请修改为实际使用的绝对路径,例如:/usr/local/coreseek/var/...
    binlog_path         =                                                       #关闭binlog日志
}
  • 建立索引。启动服务

# 建立所有索引(或者执行下面两条)
E:/__Work/coreseek-4.1-win32/bin/indexer -c E:/__Work/coreseek-4.1-win32/bin/coreseek.conf --all --rotate

# 建立指定索引
E:/__Work/coreseek-4.1-win32/bin/indexer -c E:/__Work/coreseek-4.1-win32/bin/coreseek.conf articles
E:/__Work/coreseek-4.1-win32/bin/indexer -c E:/__Work/coreseek-4.1-win32/bin/coreseek.conf article_photos


# sphinx啟動
E:/__Work/coreseek-4.1-win32/bin/searchd -c E:/__Work/coreseek-4.1-win32/bin/coreseek.conf