【问题标题】:SPHINX SEARCH: Does searchd has to run as a service to make it work with PHP?SPHINX SEARCH:searchd 是否必须作为服务运行才能与 PHP 一起使用?
【发布时间】:2010-09-29 20:28:13
【问题描述】:

我整天都在处理这个问题。但不要让它工作。

我可以通过 CMD 搜索并在我的索引表上获取结果,但我在尝试理解 php 的 sphinxapi 时遇到问题,我什至现在还不完全了解如何编写查询并获得结果有人可以帮我看看是否这东西行得通。

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

忽略我的 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?
?>

【问题讨论】:

    标签: php api search-engine sphinx


    【解决方案1】:

    试试这个

       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

    【讨论】:

    • 感谢您的帮助,我终于设法让 searchd 运行,但是您编写的 php 代码,当我尝试它时,它只是永远加载并且没有任何反应,然后它只是显示一个空白页面。
    • 您在控制台中看到任何消息吗?连接到 searchd 时很可能会超时。尝试添加 SetServer (sphinxsearch.com/docs/current.html#api-func-setserver) 以确保您连接到正确的主机/端口。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多