Book Image

Sphinx Search Beginner's Guide

By : Abbas Ali
Book Image

Sphinx Search Beginner's Guide

By: Abbas Ali

Overview of this book

Table of Contents (15 chapters)
Sphinx Search
Credits
About the Author
Acknowledgement
About the Reviewers
www.PacktPub.com
Preface

Time for action - querying Sphinx using MySQL CLI


  1. 1. Create the file /usr/local/sphinx/etc/sphinx-ql.conf and add the following code:

    source items
    {
    type = mysql
    sql_host = localhost
    sql_user = root
    sql_pass =
    sql_db = sphinx_conf
    sql_query = SELECT id, title, content, \
    UNIX_TIMESTAMP(created) AS created FROM items
    sql_attr_timestamp = created
    }
    index items
    {
    source = items
    path = /usr/local/sphinx/var/data/items-ql
    charset_type = utf-8
    }
    searchd
    {
    listen = localhost:9306:mysql41
    log = /usr/local/sphinx/var/log/ql-searchd.log
    query_log = /usr/local/sphinx/var/log/ql-query.log
    pid_file = /usr/local/sphinx/var/log/ql-searchd.pid
    }
    
  2. 2. Create the index by running the indexer utility:

    $/usr/local/sphinx/bin/indexer -c /usr/local/sphinx/etc/sphinx-ql.conf --all
    
  3. 3. Start the searchd daemon:

    $/usr/local/sphinx/bin/searchd -c /usr/local/sphinx/etc/sphinx-ql.conf
    
  4. 4. Connect to the MySQL CLI program:

    $mysql -u dbuser pdbpass -h localhost -P 9306
    
  5. 5. The previous command will connect to the MySQL server...