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 - Sphinx in action


Let's see an example of how Sphinx works. We will create an index and then search it using the Sphinx command line utility as well as the PHP client implementation. So let's begin:

  1. 1. Firstly, create a MySQL database named test, if it is not already there:

    CREATE DATABASE test;
    

    Sphinx ships with a sample configuration file and a sample database table to be used for demo purposes. The SQL for the table is located at /usr/local/sphinx/etc/example.sql and it contains the following SQL:

    DROP TABLE IF EXISTS test.documents;
    CREATE TABLE test.documents
    (
    id INTEGER PRIMARY KEY NOT NULL AUTO_INCREMENT,
    group_id INTEGER NOT NULL,
    group_id2 INTEGER NOT NULL,
    date_added DATETIME NOT NULL,
    title VARCHAR(255) NOT NULL,
    content TEXT NOT NULL
    );
    REPLACE INTO test.documents ( id, group_id, group_id2, date_added, title, content ) VALUES
    ( 1, 1, 5, NOW(), 'test one', 'this is my test document number one. also checking search within phrases.' ),
    ( 2, 1, 6, NOW(), 'test...