SPHINX SEARCH:searchd是否必须作为服务运行才能使其与PHP一起使用?

时间:2010-09-29 12:18:14

标签: php api search-engine sphinx

我整天都在努力工作。但是不要让它发挥作用。

我可以通过CMD搜索并在我的索引表上获得结果但是我在尝试理解sphinxapi for php时遇到了问题,我现在甚至没有完全如何编写查询并获得结果可以有人帮助我查看是否这件事有用。

我们如何为SPHINX写一个PHP查询
数据库=搜索测试
TABLE =文件

忽略我的sphinx.conf文件

    type                    = mysql
sql_host                = localhost
sql_user                = root
sql_pass                = sqlpass
sql_db                  = searchtest
sql_port                = 3306  # optional, default is 3306


sql_query               = \
    SELECT * \
    FROM documents
}


index searchtest
{
    source                  = src1
    path                    = C:/xampp/htdocs/sphinx/data/searchtest
    docinfo                 = extern
    charset_type            = sbcs
}


indexer
{
    mem_limit               = 32M
}


searchd
{
    port                    = 9312
    log                 = C:/xampp/htdocs/sphinx/log/searchd.log
    query_log               = C:/xampp/htdocs/sphinx/log/query.log
    read_timeout            = 5
    max_children            = 30
    pid_file                = C:/xampp/htdocs/sphinx/log/searchd.pid.pid
    max_matches             = 1000
    seamless_rotate         = 0
    preopen_indexes         = 0
    unlink_old              = 1
}

运行索引器后 - 所有文件都出现在/ data目录中,但/ log目录为空

现在我如何为php编写查询? 有人可以帮我写一个查询,在所有表中搜索“mimmi”并显示结果吗?

   <?php
  include('sphinxapi.php');

  $cl = new SphinxClient();

 //what to write here, please help stackoverflow?
?>

1 个答案:

答案 0 :(得分:2)

试试这个

   include('sphinxapi.php');
   $cl = new SphinxClient();
   $result = $cl->Query("mimmi");
   print_r($result);

http://www.sphinxsearch.com/docs/current.html#api-funcgroup-querying

是的,必须运行searchd才能正常运行。首先,使用“--console”选项尝试它,当你让它工作时,“ - install”服务。

http://www.sphinxsearch.com/docs/current.html#ref-searchd

相关问题