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 - querying Sphinx using MySQL CLI

  1. Create the file /usr/local/sphinx/etc/sphinx-ql.conf and add the following code:
    source items
    {
    type = mysql
    sql_host = localhost
    sql_user = root
    sql_pass =
    sql_db = sphinx_conf
    sql_query = SELECT id, title, content, \
    UNIX_TIMESTAMP(created) AS created FROM items
    sql_attr_timestamp = created
    }
    index items
    {
    source = items
    path = /usr/local/sphinx/var/data/items-ql
    charset_type = utf-8
    }
    searchd
    {
    listen = localhost:9306:mysql41
    log = /usr/local/sphinx/var/log/ql-searchd.log
    query_log = /usr/local/sphinx/var/log/ql-query.log
    pid_file = /usr/local/sphinx/var/log/ql-searchd.pid
    }
    
  2. Create the index by running the indexer utility:
    $/usr/local/sphinx/bin/indexer -c /usr/local/sphinx/etc/sphinx-ql.conf ...

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