coreseek 實現中文全文索引 記錄
本文只記錄了一些安裝和部分功能的操作,詳細的引數說明和工具使用手冊請見官方:
MySQL安裝
MySQL安裝
[root@59-Mysql-Test ~]# unzip mysql-5.5.46.zip
[root@59-Mysql-Test ~]# cd mysql-5.5.46
[root@59-Mysql-Test mysql-5.5.46]# cd cmake/
[root@59-Mysql-Test cmake]# chmod +x configure.pl
[root@59-Mysql-Test cmake]# ./configure.pl
[root@59-Mysql-Test cmake]# make && make install
配置/etc/my.cnf
[root@59-Mysql-Test cmake]# cd /usr/local/mysql/
[root@59-Mysql-Test mysql]# cp scripts/mysql_install_db .
[root@59-Mysql-Test mysql]# ./mysql_install_db
[root@59-Mysql-Test mysql]# cp scripts/mysql_install_db .
[root@59-Mysql-Test mysql]# ./mysql_install_db
[root@59-Mysql-Test mysql]# service mysql start
Starting MySQL.....[ OK ]
[root@59-Mysql-Test mysql]# /usr/local/mysql/bin/mysqladmin -u root password 'password'
Starting MySQL.....[ OK ]
[root@59-Mysql-Test mysql]# /usr/local/mysql/bin/mysqladmin -u root password 'password'
[root@59-Mysql-Test mysql]# /usr/local/mysql/bin/mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.5.46-log Source distribution
Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'password' WITH GRANT OPTION;
Query OK, 0 rows affected (0.00 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.01 sec)
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.5.46-log Source distribution
Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'password' WITH GRANT OPTION;
Query OK, 0 rows affected (0.00 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.01 sec)
配置sphinxSE資料庫儲存引擎
[root@59-Mysql-Test ~]# tar zxvf coreseek-4.1-beta.tar.gz
[root@59-Mysql-Test ~]# cd coreseek-4.1-beta
[root@59-Mysql-Test coreseek-4.1-beta]# cp csft-4.1/mysqlse/ ~/mysql-5.5.46/storage/sphinx -r
[root@59-Mysql-Test coreseek-4.1-beta]# cd ~/mysql-5.5.46
[root@59-Mysql-Test mysql-5.5.46]# cmake . -DCMAKE_BUILD_TYPE=Release -DWITH_SPHINX_STORAGE_ENGINE=1
[root@59-Mysql-Test mysql-5.5.46]# cmake . -DCMAKE_BUILD_TYPE=Release -DWITH_SPHINX_STORAGE_ENGINE=1
[root@59-Mysql-Test mysql-5.5.46]# make
[root@59-Mysql-Test mysql-5.5.46]# cp storage/sphinx/ha_sphinx.so /usr/local/mysql/lib/plugin/
[root@59-Mysql-Test mysql-5.5.46]# chown mysql.mysql /usr/local/mysql/lib/plugin/ha_sphinx.so
mysql> INSTALL PLUGIN sphinx SONAME 'ha_sphinx.so';
Query OK, 0 rows affected (0.19 sec)
mysql> show engines;
+--------------------+---------+------------------------------------------------------------+--------------+------+------------+
| Engine | Support | Comment | Transactions | XA | Savepoints |
+--------------------+---------+------------------------------------------------------------+--------------+------+------------+
| CSV | YES | CSV storage engine | NO | NO | NO |
| PERFORMANCE_SCHEMA | YES | Performance Schema | NO | NO | NO |
| MyISAM | YES | MyISAM storage engine | NO | NO | NO |
| InnoDB | DEFAULT | Supports transactions, row-level locking, and foreign keys | YES | YES | YES |
| MRG_MYISAM | YES | Collection of identical MyISAM tables | NO | NO | NO |
| SPHINX | YES | Sphinx storage engine 2.0.2-dev ($Revision: 2917) | NO | NO | NO |
| MEMORY | YES | Hash based, stored in memory, useful for temporary tables | NO | NO | NO |
+--------------------+---------+------------------------------------------------------------+--------------+------+------------+
7 rows in set (0.00 sec)
安裝配置coreseek
[root@59-Mysql-Test ~]# cd coreseek-4.1-beta
[root@59-Mysql-Test coreseek-4.1-beta]# cd mmseg-3.2.14/
[root@59-Mysql-Test mmseg-3.2.14]# ./configure --prefix=/usr/local/mmseg
[root@59-Mysql-Test mmseg-3.2.14]# make && make install
[root@59-Mysql-Test mmseg-3.2.14]# cd ../csft-4.1/
[root@59-Mysql-Test csft-4.1]# sh buildconf.sh
[root@59-Mysql-Test csft-4.1]# ./configure --prefix=/usr/local/coreseek --without-unixodbc --with-mmseg --with-mmseg-includes=/usr/local/mmseg/include/mmseg/ --with-mmseg-libs=/usr/local/mmseg/lib/ --with-mysql
[root@59-Mysql-Test csft-4.1]# make && make install
匯入測試資料
[root@59-Mysql-Test ~]# /usr/local/mysql/bin/mysql -u root -p < ~/coreseek-4.1-beta/csft-4.1/example.sql
配置coreseek
[root@59-Mysql-Test ~]# vi /usr/local/coreseek/etc/csft.conf
source src1
{
type = mysql
sql_host = localhost
sql_user = root
sql_pass = password
sql_db = test
sql_port = 3306 # optional, default is 3306
sql_sock = /tmp/mysql.sock
sql_query_pre = SET NAMES utf8
sql_query = \
SELECT id, group_id, UNIX_TIMESTAMP(date_added) AS date_added, title, content \
FROM documents
sql_attr_uint = group_id
sql_attr_timestamp = date_added
sql_query_info = iSELECT * FROM documents WHERE id=$id
}
index test1
{
source = src1
path = /usr/local/coreseek/var/data/test1
docinfo = extern
charset_type = zh_cn.utf-8
mlock = 0
morphology = none
min_word_len = 1
html_strip = 0
charset_dictpath = /usr/local/mmseg/etc/
ngram_len = 0
}
indexer
{
mem_limit = 32M
}
searchd
{
port = 9312
log = /usr/local/coreseek/var/log/searchd.log
query_log = /usr/local/coreseek/var/log/query.log
read_timeout = 5
max_children = 30
pid_file = /usr/local/coreseek/var/log/searchd.pid
max_matches = 1000
seamless_rotate = 1
preopen_indexes = 0
unlink_old = 1
}
構建索引
[root@59-Mysql-Test ~]# /usr/local/coreseek/bin/indexer -c /usr/local/coreseek/etc/csft.conf --all
Coreseek Fulltext 4.1 [ Sphinx 2.0.2-dev (r2922)]
Copyright (c) 2007-2011,
Beijing Choice Software Technologies Inc ()
using config file '/usr/local/coreseek/etc/csft.conf'...
indexing index 'test1'...
collected 4 docs, 0.0 MB
sorted 0.0 Mhits, 100.0% done
total 4 docs, 193 bytes
total 0.021 sec, 8926 bytes/sec, 184.99 docs/sec
total 3 reads, 0.000 sec, 0.1 kb/call avg, 0.0 msec/call avg
total 9 writes, 0.001 sec, 0.1 kb/call avg, 0.1 msec/call avg
Coreseek Fulltext 4.1 [ Sphinx 2.0.2-dev (r2922)]
Copyright (c) 2007-2011,
Beijing Choice Software Technologies Inc ()
using config file '/usr/local/coreseek/etc/csft.conf'...
indexing index 'test1'...
collected 4 docs, 0.0 MB
sorted 0.0 Mhits, 100.0% done
total 4 docs, 193 bytes
total 0.021 sec, 8926 bytes/sec, 184.99 docs/sec
total 3 reads, 0.000 sec, 0.1 kb/call avg, 0.0 msec/call avg
total 9 writes, 0.001 sec, 0.1 kb/call avg, 0.1 msec/call avg
測試
[root@59-Mysql-Test ~]# /usr/local/coreseek/bin/search -c /usr/local/coreseek/etc/csft.conf number
Coreseek Fulltext 4.1 [ Sphinx 2.0.2-dev (r2922)]
Copyright (c) 2007-2011,
Beijing Choice Software Technologies Inc ()
using config file '/usr/local/coreseek/etc/csft.conf'...
index 'test1': query 'number ': returned 3 matches of 3 total in 0.000 sec
displaying matches:
1. document=1, weight=1442, group_id=1, date_added=Wed Nov 25 11:20:27 2015
id=1
group_id=1
group_id2=5
date_added=2015-11-25 11:20:27
title=test one
content=this is my test document number one. also checking search within phrases.
2. document=2, weight=1442, group_id=1, date_added=Wed Nov 25 11:20:27 2015
id=2
group_id=1
group_id2=6
date_added=2015-11-25 11:20:27
title=test two
content=this is my test document number two
3. document=4, weight=1442, group_id=2, date_added=Wed Nov 25 11:20:27 2015
id=4
group_id=2
group_id2=8
date_added=2015-11-25 11:20:27
title=doc number four
content=this is to test groups
words:
1. 'number': 3 documents, 3 hits
Coreseek Fulltext 4.1 [ Sphinx 2.0.2-dev (r2922)]
Copyright (c) 2007-2011,
Beijing Choice Software Technologies Inc ()
using config file '/usr/local/coreseek/etc/csft.conf'...
index 'test1': query 'number ': returned 3 matches of 3 total in 0.000 sec
displaying matches:
1. document=1, weight=1442, group_id=1, date_added=Wed Nov 25 11:20:27 2015
id=1
group_id=1
group_id2=5
date_added=2015-11-25 11:20:27
title=test one
content=this is my test document number one. also checking search within phrases.
2. document=2, weight=1442, group_id=1, date_added=Wed Nov 25 11:20:27 2015
id=2
group_id=1
group_id2=6
date_added=2015-11-25 11:20:27
title=test two
content=this is my test document number two
3. document=4, weight=1442, group_id=2, date_added=Wed Nov 25 11:20:27 2015
id=4
group_id=2
group_id2=8
date_added=2015-11-25 11:20:27
title=doc number four
content=this is to test groups
words:
1. 'number': 3 documents, 3 hits
插入中文測試資料
INSERT INTO test.`documents` VALUES
(NULL,3,5,NOW(),'MySQL 學習','學習MySQL的全文索引'),
(NULL,4,6,NOW(),'中國','中華人民共和國'),
(NULL,5,7,NOW(),'今天比較冷','今天零下好幾度'),
(NULL,6,8,NOW(),'故鄉','故鄉在哪裡'),
(NULL,7,9,NOW(),'你好','同志們大家好');
建立表t1 作為索引表
CREATE TABLE t1
(
id INTEGER UNSIGNED NOT NULL,
weight INTEGER NOT NULL,
QUERY VARCHAR(3072) NOT NULL,
group_id INTEGER,
INDEX(QUERY)
) ENGINE=SPHINX CONNECTION="sphinx://127.0.0.1:9312/test1";
mysql> SELECT d.id,d.title,d.content FROM t1 JOIN documents AS d ON t1.id = d.id AND t1.query = '故鄉';
+----+--------+-----------------+
| id | title | content |
+----+--------+-----------------+
| 8 | 故鄉 | 故鄉在哪裡 |
+----+--------+-----------------+
1 row in set (0.01 sec)
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/29320885/viewspace-1846278/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- mysql中文全文索引的記錄MySql索引
- coreseek實戰(一):windows下coreseek的安裝與測試Windows
- websocket web 實現記錄Web
- lnmp+coreseek實現站內全文檢索(安裝篇)LNMP
- oracle全文索引之如何實現查詢Oracle索引
- 利用Oracle的全文索引實現切詞功能Oracle索引
- Centos下Sphinx中文分詞編譯安裝測試---CoreSeekCentOS中文分詞編譯
- Rust 實現日誌記錄功能Rust
- 記錄:瀑布流最佳實現方案
- mysql中文進行全文索引支援問題MySql索引
- 深度解析 Lucene 輕量級全文索引實現原理索引
- 案例:商品瀏覽記錄的實現
- Easyui datagrid 實現表格記錄拖拽UI
- QQ聊天記錄儲存如何實現?
- Go語言實現位元組記錄鎖Go
- Spring AOP 實現業務日誌記錄Spring
- MX記錄獲取元件(vb實現) (轉)元件
- Coreseek 安裝出現 Makefile.in 檔案找不到
- 欄位修改記錄操作日誌的實現
- 記錄三種實現圖片模糊的方法
- 實現使用者的歷史記錄功能
- 記錄---實現一個支援@的輸入框
- 記錄---實現抖音 “影片無限滑動“效果
- MySQL 為什麼全文索引查中文找不結果MySql索引
- 專案需要實現按鈕懸浮的功能, 實現後的記錄
- eXo 如何實現中文支援?
- 基於AOP和ThreadLocal實現日誌記錄thread
- vue-awesome-form的實現及踩坑記錄VueORM
- 【專案記錄】個人主頁設計和實現
- thinkphp 利用中介軟體 實現日誌操作記錄PHP
- Django實現教育平臺全程記錄-----後臺管理Django
- postgresql通過建立規則(RULE)實現表記錄SQL
- 記錄---前端如何實現檔案的線上預覽?前端
- 動態記憶體開闢實現通訊錄記憶體
- 使用 HTML 實現截圖-html2canvas使用記錄HTMLCanvas
- 介面自動化之實現日誌記錄封裝封裝
- 介面測試返回結構對比實現思路記錄
- Laravel + Elasticsearch 實現中文搜尋LaravelElasticsearch