First, install the compilation tool yum install make GCC g++ gcc-c++ libtool autoconf automake imake mysql-devel libxml2-devel expat-devel
Second, go to install folder for example: cd/usr/loacl/
Run the following command to download and unzip the installation package
wget http://www.xunsearch.com/download/xunsearch-full-latest.tar.bz2TAR-XJF xunsearch-full-latest.tar.bz2
Execute the installation script, follow the prompts, mainly to enter xunsearch
the installation directory of the software package, it is strongly recommended to plan a directory separately, not to be mixed in the other software directory.
CD xunsearch-full-1.3.0/sh setup. sh
The first installation, the process may be a little longer, please do not worry, you can brew a cup of tea while you wait.
- If your SDK calls and
xunsearch
service side is not on the same server, use the-B inet mode to start the script, and pay attention to similar iptables
's firewall to control , xunsearch
, 8383/8384
Two-port access rights. The startup script uses the following examples: bin/xs-ctl.sh-b local start // Listen on the local loopback address 127.0.0.1 bin/xs-ctl.sh-b inet start // Listen on all local IP addresses bin/xs-ctl.sh-b a.b.c.d start // Listen on the specified IP I am not on the same server, so I chose this one (bin/xs-ctl.sh-b 195.241.23.32 start) bin/xs-ctl.sh-b Unix start // listen to Tmp/indexd.sock and Tmp/searchd.sock respectively
- Configure the firewall to turn on 8383 ports, 8384 ports
vi/etc/sysconfig/iptablesnew# allows port 8383 through firewall new# Allow 8384 ports to pass through the firewall
/etc/init.d/iptables Restart #重启防火墙使配置生效
- Use Netstat-anlpt to view the port (kill the process that consumes the port9 process ID)
- Detecting the operating conditions of the PHP-SDK
$prefix #替换成你的安装目录
- Now that the installation and preparation work is complete, you can start using xunsearch php-sdk to develop your own search application.
- indexing Creating a database table to index
Create library: Creation database ' test2 ' default CHARACTER SET UTF8 COLLATE utf8_general_ci;
CREATE TABLE: ...
Configure the INI file in/usr/local/xunsearch/sdk/php/app first:
Project.name = Source
project.default_charset = utf-8
server.index = 23.27.127.32:8383
Server.search = 23.27.127.32:8384
[id]
type = id
[product_name]
Type = title
[Product_model]
index = self
Import MySQL data into Xunsearch:/usr/local/xunsearch/sdk/php/util/indexer.php--rebuild--source=mysql://yourdbuser:[email protected]/yourdbname--sql= "Select Id,product_name,product_model from Products"--project=source
Above is the server section below the PHP call section
Enter keywords for search:<input type= "text" name= "keyword" size= "<?php"Echo $_post[' keyword '];? >/><input type= "Submit" Name= "sub" value= "Search"/></form>PHPEcho"<pre/>";#The introduction of interface files, in fact, you know, is a classrequire'./lib/xs.php ';//introducing the Xunsearch SDKif(isset($_post[' Sub ']) &&$_post[' keyword ']! = '){ $keyword=Trim($_post[' keyword ']);//Receive keywords $xs=NewXS (' source ');//The demo is the project name and the profile is: $sdk/app/demo.in I//$index = $xs->index; Get Index Object $search=$xs->search;//Get Search Object $search->setlimit (20); $docs=$search->setquery ($keyword)->search ();//search ' test ' Echo"<table border= ' 1 ' bordercolor= ' green ' cellspacing= ' 0 ' ><tr><th> title </th></tr>"; foreach($docs as $doc) { $subject=$search->highlight ($doc->product_name);//Highlight Caption Echo"<tr><td>".$subject." </td></tr> "; } Echo"</table>"; //$search->setquery ($keyword);///Get the top 6 and default search statements for "West Lake" related search terms//$words = $search->getrelatedquery (); Print_r ($words); }?>
Xunsearch Tutorial steps for the use of news search