views:

36

answers:

1

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?
?>
A: 

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

stereofrog
thansk for your help, i finally manage to get searchd to run, but the php code you wrote, when i try it, it just loads forever and nothing happends, then it just displays a blank page.
PIRATE_LAWRENCE
Do you see any messages in the console? Most probably it times out when connecting to searchd. Try adding SetServer (http://www.sphinxsearch.com/docs/current.html#api-func-setserver) to make sure you're connecting to the right host/port.
stereofrog