zoukankan      html  css  js  c++  java
  • [HOWTO] Install Sphinx for A Script Pro

    Hi,

    Here's a small howto on installing Sphinx Search (http://sphinxsearch.com/) and configuring it to work with Adult Script Pro. By using sphinx
    you will be able to allow users to search for video on your adult tube site by title, description and tags. The search results will be automatically
    ordered by relevance (its almost the same as using mysql MATCH_AGAINST, but faster and it can support even 1.000.000 videos).

    You will need ssh root access. The installation itself is quite easy, depending on your distribution:

    Ubuntu (tested on Ubuntu 10.10):

    sudo apt-get update
    sudo apt-get install sphinxsearch
    

    CentOs (tested on 5.4):

    yum install sphinx
    

    Configuring sphinx si also straight forward, all you need to do is edit the sphinx configuration file and add:

    source videos
    {
            type        = mysql
        sql_host    = localhost
        sql_user    = mysql-username
        sql_pass    = mysql-password
        sql_db      = mysql-database
        sql_sock    = /var/lib/mysqld/mysqld.sock (this depends on your server)
        sql_port    = 3306
    
        sql_query_pre       = SET NAMES utf8
        sql_query           = 
            SELECT v.video_id, v.title, v.description, v.mobile, v.add_time, 
             v.rating, v.total_views, v.duration, v.video_id AS video,  #added in RC4
             GROUP_CONCAT(DISTINCT t.name SEPARATOR ' ') AS tags 
            FROM video AS v 
            LEFT JOIN video_tags AS t ON (t.video_id = v.video_id) 
            WHERE v.status = 1 
            GROUP BY v.video_id
    
            sql_attr_uint           = video #added in RC4
            sql_attr_uint           = mobile
            sql_attr_uint           = total_views
            sql_attr_float          = duration
            sql_attr_float          = rating
            sql_attr_timestamp  = add_time
            sql_attr_multi          = uint categories FROM query; SELECT video_id, cat_id FROM video_category
            sql_query_info          = SELECT video_id, add_date FROM video WHERE video_id=$id
    }
    
    index videos
    {
        source          = videos
        path            = /var/lib/sphinxsearch/data/videos (this depends on your distribution)
            charset_type    = utf-8
            min_prefix_len  = 3
            enable_star     = 1
    }
    
    searchd
    {
            port            = 3312
            log                     = /var/log/sphinxsearch/searchd.log (this depends on your distribution)
            query_log       = /var/log/sphinxsearch/query.log (this depends on your distribution)
            pid_file        = /var/log/sphinxsearch/searchd.pid (this depends on your distribution)
    }

    The sphinx data and log folders might depend on your distribution.

    After this you need to create the initial index with the following command:

    indexer --all --config /path/to/your/sphinx/configuration/file.conf
    

    You will also need to create a cron file and place it into the /etc/cron.hourly (or add it to cron from cpanel or console). The script
    should be named sphinx and chmoded to 755, with the following contents:

    #!/bin/bash
    /usr/bin/indexer --all --rotate --config /path/to/your/sphinx/configuration/file.conf

    Thats it :-)

    If you dont have the time do the installation yourself, or you dont like the linux console, just drop us a email and we can do the installation
    for 49$.

    source videos
    {
            type        = mysql
        sql_host    = localhost
        sql_user    = mysql-username
        sql_pass    = mysql-password
        sql_db      = mysql-database
        sql_sock    = /var/lib/mysqld/mysqld.sock (this depends on your server)
        sql_port    = 3306
    
        sql_query_pre       = SET NAMES utf8
        sql_query           = 
            SELECT v.video_id, v.title, v.description, v.mobile, v.add_time, 
             v.rating, v.total_views, v.duration, 
             GROUP_CONCAT(DISTINCT t.name SEPARATOR ' ') AS tags 
            FROM video AS v 
            LEFT JOIN video_tags AS t ON (t.video_id = v.video_id) 
            AND v.status = 1 
            GROUP BY v.video_id
    
            sql_attr_uint           = mobile
            sql_attr_uint           = total_views
            sql_attr_float          = duration
            sql_attr_float          = rating
            sql_attr_timestamp  = add_time
            sql_attr_multi          = uint categories FROM query; SELECT video_id, cat_id FROM video_category
            sql_query_info          = SELECT video_id, add_date FROM video WHERE video_id=$id
    }
    
    index videos
    {
        source          = videos
        path            = /var/lib/sphinxsearch/data/videos (this depends on your distribution)
            charset_type    = utf-8
            min_prefix_len  = 3
            enable_star     = 1
    }
    
    searchd
    {
            port            = 3312
            log                     = /var/log/sphinxsearch/searchd.log (this depends on your distribution)
            query_log       = /var/log/sphinxsearch/query.log (this depends on your distribution)
            pid_file        = /var/log/sphinxsearch/searchd.pid (this depends on your distribution)
    }
  • 相关阅读:
    .Net学习难点讨论系列2 – 细说C#中new关键字与多态
    [翻译]搜索关键字 – 管道与过滤器模式(PipesandFilters)与装饰模式(Decorator)之间的关系
    .Net学习难点讨论系列1 – 委托与事件之事件
    [翻译]Popfly系列课程1 Popfly课程计划概览
    常用桌面虚拟化软件横向对比
    各种算法的C#实现系列1 合并排序的原理及代码分析
    博客园安家
    疑:Microsoft® Silverlight™ Tools for Visual Studio 2008 SP1的版本让人困惑
    stream_socket_client
    stream_socket_client2
  • 原文地址:https://www.cnblogs.com/94YY/p/5868435.html
Copyright © 2011-2022 走看看