使用Sphinx和PHP。 “搜索”出错:“搜索错误:。”

时间:2013-03-20 07:38:23

标签: php sphinx

我正在使用PHP测试Sphinx(教程:http://www.siteduzero.com/informatique/tutoriels/creer-un-moteur-de-recherche-avec-sphinx-et-php

如果我像这样运行“搜索”:

search -i news navigateur

我有以下错误:

index 'news': search error: .

索引器工作正常:

  

$ sudo indexer news
  Sphinx 2.0.6发布(r3473)版权所有(c)   2001-2012,Andrew Aksyonoff版权所有(c)2008-2012,Sphinx   Technologies Inc(http://sphinxsearch.com

     

使用配置文件'/usr/share/php/sphinx/etc/sphinx.conf'...   索引索引'新闻'......

     

收集了57个文档,0.7 MB分类0.1 Mhits,100.0%

     

共完成57个文档,689264个字节总计0.050秒,13684561个字节/秒,   1131.67 docs / sec

     

总共3次读数,0.000秒,115.5 kb /调用平均值,0.1毫秒/调用平均值

     

总共9次写入,0.000秒,83.5 kb /调用平均值,0.0毫秒/调用平均值

并且,使用API​​进行测试,PHP代码不会返回任何内容。有人已经有这个错误吗?

这里是配置文件:

  

索引新闻{

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

}

     

索引器{

    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 
     

}

     

来源新闻{

    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 }

感谢。

和Fabrice

2 个答案:

答案 0 :(得分:1)

刚遇到同样的问题。最后一个config参数中的邪恶根源。此命令将正常工作:

search -i news --noinfo navigateur

或者您可以从config中删除此字符串:

sql_query_info      = SELECT titre FROM news WHERE id=$id

如果你不需要它。

答案 1 :(得分:0)

这是search实用程序中的错误。

好消息是search实用程序,它只是一个测试工具,因此它并不重要。它实际上并没有用于测试以外的任何东西。

至于您的API问题,您是否正在运行searchd守护程序?

您应该使用getLastError和getLastWarning来调查原因......而不是仅仅说它返回'nothing',而不是......