Search icon
Subscription
0
Cart icon
Close icon
You have no products in your basket yet
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Sphinx Search Beginner's Guide

You're reading from  Sphinx Search Beginner's Guide

Product type Book
Published in Mar 2011
Publisher
ISBN-13 9781849512541
Pages 244 pages
Edition 1st Edition
Languages
Author (1):
Abbas Ali Abbas Ali
Profile icon Abbas Ali

Table of Contents (15) Chapters

Sphinx Search
Credits
About the Author
Acknowledgement
About the Reviewers
1. www.PacktPub.com
2. Preface
1. Setting Up Sphinx 2. Getting Started 3. Indexing 4. Searching 5. Feed Search 6. Property Search 7. Sphinx Configuration 8. What Next?

Time for action - creating index (without attributes)


  1. 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. 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 failed: '.$e->getMessage();
    }
    // We will use PHP's inbuilt XMLWriter to create the xml structure
    $xmlwriter = new XMLWriter();
    $xmlwriter->openMemory();
    $xmlwriter->setIndent(true);
    $xmlwriter->startDocument('1.0', 'UTF-8'...
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime}