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 - 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. 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 ...

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