James
James

Reputation: 1461

Using Sphinx with PHP. Error with the "search" : "Search error: ."

I'm testing Sphinx with PHP (tutorial : http://www.siteduzero.com/informatique/tutoriels/creer-un-moteur-de-recherche-avec-sphinx-et-php)

If I run "search" like this :

search -i news navigateur

I have the following error :

index 'news': search error: .

The indexer works fine :

$ sudo indexer news
Sphinx 2.0.6-release (r3473) Copyright (c) 2001-2012, Andrew Aksyonoff Copyright (c) 2008-2012, Sphinx Technologies Inc (http://sphinxsearch.com)

using config file '/usr/share/php/sphinx/etc/sphinx.conf'... indexing index 'news'...

collected 57 docs, 0.7 MB sorted 0.1 Mhits, 100.0%

done total 57 docs, 689264 bytes total 0.050 sec, 13684561 bytes/sec, 1131.67 docs/sec

total 3 reads, 0.000 sec, 115.5 kb/call avg, 0.1 msec/call avg

total 9 writes, 0.000 sec, 83.5 kb/call avg, 0.0 msec/call avg

And, testing with the API, the PHP code return nothing. Anybody already have this error ?

Here the config file :

index news {

    source = news
    path   = /usr/share/php/sphinx/var/data/news

}

indexer {

    mem_limit = 32M 

}

searchd {

    port      = 3312
    log       = /usr/share/php/sphinx/var/log/searchd/searchd.log
    query_log = /usr/share/php/sphinx/var/log/searchd/query.log
    pid_file  = /usr/share/php/sphinx/var/log/searchd/searchd.pid 

}

source news {

    type                = mysql
    sql_host            = localhost
    sql_user            = root
    sql_pass            =  
    sql_db              = siteduzero_sphinx
    sql_query_pre       = SET NAMES utf8
    sql_query           = SELECT id\
                                , categorie\
                                , titre\
                                , contenu FROM news
    sql_attr_uint       = categorie
    sql_query_info      = SELECT titre FROM news WHERE id=$id }

Thanks.

Fabrice

Upvotes: 0

Views: 1308

Answers (2)

Alex Belyaev
Alex Belyaev

Reputation: 1445

Just ran into the same problem. The root of evil in the last config parameter. This command will work correctly:

search -i news --noinfo navigateur

Or you can remove this string from config:

sql_query_info      = SELECT titre FROM news WHERE id=$id

If you don't need it.

Upvotes: 1

barryhunter
barryhunter

Reputation: 21091

It's a bug in the search utility.

The good news is the search utility, is just a testing tool, so its not critical. Its not actually used for anything other than testing.

As for your problem with the API, do you have the searchd daemon running?

Rather than just saying it returns 'nothing', you should use getLastError and getLastWarning to investigate why...

Upvotes: 0

Related Questions