Xunsearch Tutorial steps for the use of news search

Source: Internet
Author: User

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/

  1. 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

  2. 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.

  3. 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 
  4. 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 #重启防火墙使配置生效

  5. Use Netstat-anlpt to view the port (kill the process that consumes the port9 process ID)
  6. Detecting the operating conditions of the PHP-SDK
    $prefix #替换成你的安装目录
  7. Now that the installation and preparation work is complete, you can start using xunsearch php-sdk to develop your own search application.
  8. 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

  9. 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

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.