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 - create index with schema defined in configuration file


  1. 1. Modify /usr/local/sphinx/etc/sphinx-blog-xmlpipe2.conf and include the fields and attributes definition in the source block:

    source blog
    {
    type = xmlpipe2
    xmlpipe_command = /usr/bin/php /home/abbas/sphinx/makeindex.php
    xmlpipe_field = title
    xmlpipe_field = content
    xmlpipe_attr_uint = author_id
    xmlpipe_attr_timestamp = publish_date
    xmlpipe_attr_multi = category_id
    }
    index posts
    {
    source = blog
    path = /usr/local/sphinx/var/data/blog-xmlpipe2
    docinfo = extern
    charset_type = utf-8
    }
    indexer
    {
    mem_limit = 32M
    }
    
  2. 2. Modify the makeindex.php script and remove the sphinx:schema element along with all its sub-elements:

    <?php
    // Database connection credentials
    $dsn ='mysql:dbname=myblog;host=localhost';
    $user = 'root';
    $pass = '';
    // Instantiate the PDO (PHP 5 specific) class
    try {
    $dbh = new PDO($dsn, $user, $pass);
    } catch (PDOException $e){
    echo'Connection failed: '.$e->getMessage();
    }
    // We will use PHP's inbuilt...