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

推荐订阅源

V2EX - 技术
V2EX - 技术
酷 壳 – CoolShell
酷 壳 – CoolShell
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
阮一峰的网络日志
阮一峰的网络日志
GbyAI
GbyAI
The Cloudflare Blog
小众软件
小众软件
MyScale Blog
MyScale Blog
IT之家
IT之家
H
Help Net Security
宝玉的分享
宝玉的分享
V
Visual Studio Blog
Hugging Face - Blog
Hugging Face - Blog
F
Fortinet All Blogs
博客园_首页
S
SegmentFault 最新的问题
MongoDB | Blog
MongoDB | Blog
The Hacker News
The Hacker News
有赞技术团队
有赞技术团队
Microsoft Security Blog
Microsoft Security Blog
Know Your Adversary
Know Your Adversary
Project Zero
Project Zero
P
Palo Alto Networks Blog
博客园 - 聂微东
罗磊的独立博客
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
Engineering at Meta
Engineering at Meta
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
U
Unit 42
Spread Privacy
Spread Privacy
NISL@THU
NISL@THU
Cisco Talos Blog
Cisco Talos Blog
Last Week in AI
Last Week in AI
L
Lohrmann on Cybersecurity
J
Java Code Geeks
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
Cyberwarzone
Cyberwarzone
G
Google Developers Blog
C
Cybersecurity and Infrastructure Security Agency CISA
大猫的无限游戏
大猫的无限游戏
Microsoft Azure Blog
Microsoft Azure Blog
L
LangChain Blog
The GitHub Blog
The GitHub Blog
Jina AI
Jina AI
Blog — PlanetScale
Blog — PlanetScale
C
Cyber Attacks, Cyber Crime and Cyber Security
L
LINUX DO - 热门话题
T
Tailwind CSS Blog
雷峰网
雷峰网
C
Cisco Blogs

博客园 - 懒牛拉车

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