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 - creating indexes for distributed searching


  1. 1. Create the configuration file on the first server (192.168.1.1) at /usr/local/sphinx/etc/sphinx-distributed.conf with the following content:

    source items
    {
    type = mysql
    sql_host = localhost
    sql_user = root
    sql_pass =
    sql_db = sphinx_conf
    # Query to set MySQL variable @total
    #which holds total num of rows
    sql_query_pre = SELECT @total := count(id) FROM items
    # Set a variable to hold the sql query
    # We are using CONCAT to use a variable in limit clause
    # which is not possible in direct query execution
    sql_query_pre = SET @sql = CONCAT('SELECT * FROM items \
    limit 0,', CEIL(@total/2))
    # Prepare the sql statement
    sql_query_pre = PREPARE stmt FROM @sql
    # Execute the prepared statement. This will return rows
    sql_query = EXECUTE stmt
    # Once documents are fetched, drop the prepared statement
    sql_query_post = DROP PREPARE stmt
    sql_attr_timestamp = created
    }
    index items
    {
    source = items
    path = /usr/local/sphinx/var/data/items-distributed...