Coreseek Mysql Installation and testing (Chinese participle and Chinese full-text search)

Source: Internet
Author: User
Tags character set curl create database mysql import automake

Coreseek installation is troublesome, the Official handbook is not very good support for this. Coreseek is a Chinese word segmentation and Full-text search software based on Sphinx. This article is to install and debug Coreseek under the Mac OS x system.

Errors during installation if the warning warning is ignored, if it is error, you must deal with.

Coreseek is supported by three sources of data, one is known as MySQL, one is XML file, the other is Python. Python, however, is the universal data type. In this coreseek installation test tutorial, only the sample data source is an XML file and MySQL.

Official Manual Address: HTTP://WWW.CORESEEK.CN/PRODUCTS-INSTALL/INSTALL_ON_MACOSX

Setting environment variables


$ export Path=/usr/local/bin: $PATH

$ export LC_ALL=ZH_CN. UTF-8

$ export. UTF-8

Second, the installation of dependent libraries: M4, autoconf, Automake, Libtool.

Note: Do not brew install to install because there is a requirement for the version of the installed library.

$ Curl-o-L http://mirrors.kernel.org/gnu/m4/m4-1.4.13.tar.gz

$ TAR-XZVF m4-1.4.13.tar.gz

$ CD m4-1.4.13

$ sudo./configure--prefix=/usr/local/opt

$ sudo make

$ sudo make install

$ cd ...

$ Curl-o-L http://mirrors.kernel.org/gnu/autoconf/autoconf-2.65.tar.gz

$ TAR-XZVF autoconf-2.65.tar.gz

$ CD autoconf-2.65

$ sudo./configure--prefix=/usr/local/opt

$ sudo make

$ sudo make install

$ cd ...

$ Curl-o-L http://mirrors.kernel.org/gnu/automake/automake-1.11.tar.gz

$ tar xzvf automake-1.11.tar.gz

$ CD automake-1.11

$./configure--prefix=/usr/local/opt

$ sudo make

$ sudo make install

$ cd ...

$ Curl-o-L http://mirrors.kernel.org/gnu/libtool/libtool-2.2.6b.tar.gz

$ tar xzvf libtool-2.2.6b.tar.gz

$ CD libtool-2.2.6b

$ sudo./configure--prefix=/usr/local/opt

$ sudo make

$ sudo make install

$ cd ...

Third, the installation of MySQL.

1, the installation of MySQL install itself

2, look for MySQL header file address and library file address. I use

Brew Install MySQL

Installed MySQL, header file address and library file address are/usr/local/cellar/mysql/5.6.17_1/include/mysql and/usr/local/cellar/mysql/5.6.17_1/lib respectively.

The header file address is the directory where the mysql.h resides, and the library file address is the directory where LIBMYSQLCLIENT.A resides.

Four, download Coreseek.

$ Curl-o-L http://www.coreseek.cn/uploads/csft/3.2/coreseek-3.2.14.tar.gz

$ tar xzvf coreseek-3.2.14.tar.gz

$ CD coreseek-3.2.14

Under the coreseek-3.2.14 folder there are mmseg and csft and Testpack. MMSEG is a word segmentation service, csft is the core service of Coreseek, Testpack is a test case.

V. Installation of MMSEG

$ CD mmseg-3.2.14

$ sudo./bootstrap

$ sudo./configure--prefix=/usr/local/opt/mmseg3

$ sudo make

$ sudo make install

$ cd ...

When make, you may have an error, as follows

File included from Css/thesaurusdict.cpp:6:

.. /src/css/thesaurusdict.h:12:17:error:expected namespace Name

using namespace __gnu_cxx;

^

Css/thesaurusdict.cpp:79:15:warning:result of comparison against a string

Literal is unspecified (use strncmp instead) [-wstring-compare]

if (filename = = "-") {

^ ~~~

Css/thesaurusdict.cpp:116:15:warning:result of comparison against a string

Literal is unspecified (use strncmp instead) [-wstring-compare]

if (filename!= "-") {

^ ~~~

2 warnings and 1 error generated.

MAKE[2]: * * * [Thesaurusdict.lo] Error 1

MAKE[1]: * * * [install-recursive] Error 1

The make process is terminated at this time. The reason is because the compiler version is too high cause, modify method: 1 is to reduce the compiler version, anyway, I do not want to kill. Method 2 is as follows:

Vim Src/css/thesaurusdict.h

# # #在头部找到: #include <string>

# # #再其下加入一行代码:

#include <ext/hash_map>

After the changes are saved and quit, go back to sudo make, there is no error level errors, and then sudo make install can.

Vi. installation of Coreseek

$ CD csft-3.2.14

$ sudo sh buildconf.sh

$ sudo./configure--prefix=/usr/local/opt/coreseek--without-unixodbc--with-mmseg--with-mmseg-includes=/usr/local /opt/mmseg3/include/mmseg/--with-mmseg-libs=/usr/local/opt/mmseg3/lib/--with-mysql--with-mysql-includes=/usr/ Local/cellar/mysql/5.6.17_1/include/mysql--with-mysql-libs=/usr/local/cellar/mysql/5.6.17_1/lib

$ sudo make

$ sudo make install

$ cd ...

In the./configure, the parameter--with-mysql-includes is the MySQL header file location,--with-mysql-libs is the MySQL library file location, Please replace the MySQL header file address and library file address recorded in the third step of this coreseek installation tutorial.

Error-level errors may appear when make, and must be modified if the make program is stopped running. The error prompts are as follows:

Phinxexpr.cpp:1047:11:error:use of undeclared identifier ' Expreval '

T val = expreval (This->m_parg, Tmatch); ' This ' fixes gcc ...

Workaround: Modify the source code.

Vim Src/sphinxexpr.cpp

Replace T val = expreval (This->m_parg, Tmatch) with t val = This->expreval (This->m_parg, Tmatch).

is to add a "this->", is the file of all the Expreval () functions are modified, there are three or four.

Save and exit after modification, and then sudo make, then sudo make install.

Seven, test XML data

$ CD Testpack

#测试编码是否正确显示中文, if not Chinese, please see the first step of this Coreseek installation test tutorial

$ cat Var/test/test.xml

# test the effect of mmseg participle

$/usr/local/opt/mmseg3/bin/mmseg-d/usr/local/opt/mmseg3/etc Var/test/test.xml

# establishes the index to retrieve.

$/usr/local/opt/coreseek/bin/indexer-c etc/csft.conf--all

#全文搜索 "Network Search"

$/usr/local/opt/coreseek/bin/search-c etc/csft.conf Network Search

If there is an error in establishing the retrieved index, fatal:failed to lock Var/data/xml.spl:resource temporarily unavailable, would not index. Try--rotate option.

The revision should read

$/usr/local/opt/coreseek/bin/indexer-c etc/csft.conf--all--rotate

Test MySQL data source

CD Testpack

1, modify the configuration file, the file is located in testpack/etc/csft_mysql.conf

Vim etc/csft_mysql.conf

My csft_mysql.conf file is as follows: Remember to change the MySQL sql_host,sql_user,sql_pass,sql_db,sql_port to your own, and change the road strength to your own path.

For more information #MySQL数据源配置, please see: http://www.coreseek.cn/products-install/mysql/

#请先将var/test/documents.sql to import the database and configure the following MySQL user password database

#源定义

SOURCE MySQL

{

Type = MySQL

Sql_host = localhost

Sql_user = root

Sql_pass = 8823150

sql_db = Test

Sql_port = 3306

Sql_query_pre = SET NAMES UTF8

Sql_query = SELECT ID, group_id, Unix_timestamp (date_added) as date_added, title, content from documents

#sql_query第一列id需为整数

#title, content as a string/text field, Full-text indexed

Sql_attr_uint = group_id #从SQL读取到的值必须为整数

Sql_attr_timestamp = date_added #从SQL读取到的值必须为整数, as time attribute

Sql_query_info_pre = set NAMES UTF8 #命令行查询时, setting the correct character set

Sql_query_info = SELECT * from documents WHERE id= $id #命令行查询时 to read raw data information from the database

}

#index定义

Index MySQL

{

Source = MySQL #对应的source名称

Path =/users/lane/coreseek-3.2.14/testpack/var/data/mysql #请修改为实际使用的绝对路径, for example:/usr/local/coreseek/var/...

DocInfo = extern

Mlock = 0

Morphology = None

Min_word_len = 1

Html_strip = 0

For more information #中文分词配置, please see: http://www.coreseek.cn/products-install/coreseek_mmseg/

Charset_dictpath =/usr/local/opt/mmseg3/etc/#BSD, Linux environment settings,/end of symbol

#charset_dictpath = etc/#Windows环境下设置,/symbol end, best given absolute path, for example: 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 =/users/lane/coreseek-3.2.14/testpack/var/log/searchd_mysql.pid #请修改为实际使用的绝对路径, for example:/usr/local/coreseek/ var/...

Log =/users/lane/coreseek-3.2.14/testpack/var/log/searchd_mysql.log #请修改为实际使用的绝对路径, for example:/usr/local/coreseek/var/ ...

Query_log =/users/lane/coreseek-3.2.14/testpack/var/log/query_mysql.log #请修改为实际使用的绝对路径, for example:/usr/local/coreseek/ var/...

}

2, to the MySQL import test data

The MySQL test data we use is the test database, documents data table. Please make sure that the test database exists and we will build the documents together, and the structure and data of this table are provided by Coreseek in Testpack/var/test/documents.sql

Mysql-u root-p

#输入密码

#看看, database test is not in

MySQL > show databases;

#如果test库不在请创建

MySQL > CREATE database test;

Use test;

#导入数据

Source/users/lane/coreseek-3.2.14/testpack/var/test/documents.sql

3, testing:

$ CD Testpack

# set up index for retrieval

$/usr/local/opt/coreseek/bin/indexer-c etc/csft_mysql.conf--all

#全文搜索 "Network Search"

$/usr/local/opt/coreseek/bin/search-c etc/csft_mysql.conf Network Search

If prompted with errors, please check the csft_mysql.conf path, MySQL configuration, and so on is correct.

Nine, Test Php+mysql

1. Start Service First

/usr/local/opt/coreseek/bin/searchd-c etc/csft.conf

2, PHP file

<?php

Require ("/users/lane/coreseek-3.2.14/testpack/api/sphinxapi.php");

$CL = new Sphinxclient ();

$cl->setserver (' 127.0.0.1 ', 9312);

$CL->setconnecttimeout (3);

$cl->setarrayresult (TRUE);

$CL->setmatchmode (Sph_match_any);

$res = $cl->query (' Web search ', ' * ');

Print_r ($CL);

Print_r ($res);

I have been in Linux for a day without a fix, in the Mac for half a day to get it done. And then Linux after the Linux is done.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.