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 a configuration with advanced source options


  1. 1. Create a database (or use an existing one) with the following structure and data:

    CREATE TABLE `items` (
    `id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY ,
    `title` VARCHAR( 255 ) NOT NULL ,
    `content` TEXT NOT NULL ,
    `created` DATETIME NOT NULL
    ) ENGINE = MYISAM ;
    CREATE TABLE `last_indexed` (
    `id` INT NOT NULL
    ) ENGINE = MYISAM ;
    INSERT INTO `last_indexed` (
    `id`
    )
    VALUES (
    '0'
    );
    
  2. 2. Add a few rows to the items table so that we get some data to index.

  3. 3. Create the Sphinx configuration file /usr/local/sphinx/etc/sphinx-src-opt.conf with the following content:

    source items
    {
    type = mysql
    sql_host = localhost
    sql_user = root
    sql_pass =
    sql_db = sphinx_conf
    # Set the charset of returned data to utf8
    sql_query_pre = SET NAMES utf8
    # Turn of the query cache
    sql_query_pre = SET SESSION query_cache_type = OFF
    sql_query_range = SELECT MIN(id), MAX(id) FROM items \
    WHERE id >= (SELECT id FROM last_indexed)
    sql_range_step = 200...