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 basic search script


  1. 1. Add the searchd config section to /usr/local/sphinx/etc/sphinx-blog.conf:

    source blog {
    # source options
    }
    index posts {
    # index options
    }
    indexer {
    # indexer options
    }
    # searchd options (used by search daemon)
    searchd
    {
    listen = 9312
    log = /usr/local/sphinx/var/log/searchd.log
    query_log = /usr/local/sphinx/var/log/query.log
    max_children = 30
    pid_file = /usr/local/sphinx/var/log/searchd.pid
    }
    
  2. 2. Start the searchd daemon (as root user):

    $ sudo /usr/local/sphinx/bin/searchd -c /usr/local/sphinx/etc/sphinx-blog.conf
    
  3. 3. Copy the sphinxapi.php file (the class with PHP implementation of Sphinx API) from the sphinx source directory to your working directory:

    $ mkdir /path/to/your/webroot/sphinx
    $ cd /path/to/your/webroot/sphinx
    $ cp /path/to/sphinx-0.9.9/api/sphinxapi.php .
    
    
  4. 4. Create a simple_search.php script that uses the PHP client API class to search the Sphinx-blog index, and execute it in the browser:

    <?php
    require_once('sphinxapi.php...