SPHINX SEARCH: Does searchd has to run as a service to make it work with PHP?

拥有回忆 提交于 2019-12-25 04:55:22

问题


I've been working with this all day. But don't get it to work.

I can search through CMD and get results on my indexed tables but I have problems trying to understand the sphinxapi for php, i don't even now fully how to write a query and get the results can someone help me to see if this things work.

HOW DO WE WRITE A PHP QUERY FOR SPHINX
DATABASE = searchtest
TABLE = documents

overlook of my sphinx.conf file

    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
}

after running the indexer --all the files appear in the /data directory, but the /log directory is empty

now how do i write a query for php?
Can someone help me write a query that searches for "mimmi" in all tables and displays the results?

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

  $cl = new SphinxClient();

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

回答1:


Try this

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

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

Yes, searchd must be running for this to work. First, try it with "--console" option, and when you get it to work, "--install" the service.

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



来源:https://stackoverflow.com/questions/3821493/sphinx-search-does-searchd-has-to-run-as-a-service-to-make-it-work-with-php

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!