O'Reilly logo

Sphinx Search by Abbas Ali

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Time for action - creating index (without attributes)

  1. Create a new Sphinx configuration file at /usr/local/sphinx/etc/sphinx-blog-xmlpipe2.conf with the following options:
    source blog
    {
    type = xmlpipe2
    xmlpipe_command = /usr/bin/php /home/abbas/sphinx/makeindex.php
    }
    index posts
    {
    source = blog
    path = /usr/local/sphinx/var/data/blog-xmlpipe2
    docinfo = extern
    charset_type = utf-8
    }
    indexer
    {
    mem_limit = 32M
    }
    
  2. Create the PHP script /home/abbas/sphinx/makeindex.php (this script can be anywhere on your machine).
    <?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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required