1. Installation
1.01: Download to official website coreseek-3.2.14
1.02: Installation
1, download after decompression to get the source program directory coreseek-3.2.14, folder rename, simple, named Coreseek; move Coreseek folder to F:my-php\test\ (location is arbitrary);
2. "Start"-"Run"-Input cmd, open command-line window---Execute "F: Enter"--Execute "CD www\coreseek\" and go to the Coreseek directory;
3. Execute "set path=?%\ bin;%path% ". Set path, the purpose is to be able to call the bin directory Cat.exe, Iconv.exe, etc.;
4. Create the index first:
4.1: Modify the configuration file. \coreseek\etc\csft_mysql.conf (the MySQL source I used) is as follows:
#MySQL数据源配置
#源定义
SOURCE MySQL
{
Type = MySQL
Sql_host = 127.0.0.1
Sql_user = root
Sql_pass =
sql_db = PHP
Sql_port = 3306
Sql_query_pre = SET NAMES UTF8
Sql_query = SELECT o_id, O_name, o_title from otest WHERE O_start = 1
#sql_query第一列id需为整数
#title, content as a string/text field, indexed by the full text
Sql_query_info_pre = set NAMES UTF8 #命令行查询时, setting the correct character sets
Sql_query_info = SELECT * from otest where o_id= $id #命令行查询时 to read raw data information from the database
}
The rest of the sections are OK if you change the relative path to an absolute path, not another operation
4.2 Create an index in the command-line window Execution command is as follows: Bin\indexer-c etc\csft_mysql.conf--all
5, the installation of SEARCHD into a service. Execute the command as follows: Bin\searchd-c etc\csft_mysql.conf
Success is as follows:
2: Use
Header("Content-type:text/html;charset=utf-8");
Get the data to the search $keyword=$_post[' Search '];
Instantiate the Sphinx class $sphinx=New Sphinxclient();
Open service $sphinx-Setserver("LocalHost",9312); $sphinx-Setmatchmode(Sph_match_any);
Perform a data search $result=$sphinx-Query("$keyword ","*");
Get the corresponding data in the index $key=Array_keys($result[' Matches ']);
Convert to String $ids=Implode(‘,‘,$key);
Connecting to a database $conn=Mysql_connect(' localhost ',' Root ',' Root ')OrDie(' MySQL Connect failed ');
Select Database mysql_select_db(' Test ');
Set character sets Mysql_set_charset(' UTF8 ',$conn);
Set up query data $sql="SELECT * from Otest where o_id in ($ids) ";
Execute Query statement $res=Mysql_query($sql);
Set the label to append $opt=Array("Before_match"="<font style= ' font-weight:bold;color: #f00 ' >","After_match"= "</font>");
Loop the data and then append the label while ($row=mysql_fetch_assoc($res)) {
$data [] = $sphinx->buildexcerpts ($row, ' MySQL ', $keyword, $opt);
}
Print data
Print_r ($data);
Close Service
$spinx->close ();
The results of the operation are shown below:
< Span class= "indent" > < Span style= "color: #339933;" >&NBSP;
Install under Windows using Coreseek