<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <title>Execute search query</title> </head> <body><div class="manualnavbar" style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="sphinxclient.open.html">SphinxClient::open</a></div> <div class="next" style="text-align: right; float: right;"><a href="sphinxclient.resetfilters.html">SphinxClient::resetFilters</a></div> <div class="up"><a href="class.sphinxclient.html">SphinxClient</a></div> <div class="home"><a href="index.html">PHP Manual</a></div> </div><hr /><div id="sphinxclient.query" class="refentry"> <div class="refnamediv"> <h1 class="refname">SphinxClient::query</h1> <p class="verinfo">(PECL sphinx >= 0.1.0)</p><p class="refpurpose"><span class="refname">SphinxClient::query</span> — <span class="dc-title">Execute search query</span></p> </div> <div class="refsect1 description" id="refsect1-sphinxclient.query-description"> <h3 class="title">Description</h3> <div class="methodsynopsis dc-description"> <span class="modifier">public</span> <span class="type">array</span> <span class="methodname"><strong>SphinxClient::query</strong></span> ( <span class="methodparam"><span class="type">string</span> <code class="parameter">$query</code></span> [, <span class="methodparam"><span class="type">string</span> <code class="parameter">$index</code><span class="initializer"> = "*"</span></span> [, <span class="methodparam"><span class="type">string</span> <code class="parameter">$comment</code><span class="initializer"> = ""</span></span> ]] )</div> <p class="para rdfs-comment"> Connects to searchd server, runs the given search query with the current settings, obtains and returns the result set. </p> </div> <div class="refsect1 parameters" id="refsect1-sphinxclient.query-parameters"> <h3 class="title">Parameters</h3> <p class="para"> <dl> <dt> <span class="term"><em><code class="parameter">query</code></em></span> <dd> <p class="para"> Query string. </p> </dd> </dt> <dt> <span class="term"><em><code class="parameter">index</code></em></span> <dd> <p class="para"> An index name (or names). </p> </dd> </dt> <dt> <span class="term"><em><code class="parameter">comment</code></em></span> <dd> <p class="para"> </p> </dd> </dt> </dl> </p> </div> <div class="refsect1 returnvalues" id="refsect1-sphinxclient.query-returnvalues"> <h3 class="title">Return Values</h3> <p class="para"> On success, <span class="function"><strong>SphinxClient::query()</strong></span> returns a list of found matches and additional per-query statistics. The result set is a hash utilize other structures instead of hash) with the following keys and values: <table class="doctable table"> <caption><strong>Result set structure</strong></caption> <thead> <tr> <th>Key</th> <th>Value description</th> </tr> </thead> <tbody class="tbody"> <tr> <td>"matches"</td> <td>An array with found document IDs as keys and their weight and attributes values as values</td> </tr> <tr> <td>"total"</td> <td>Total number of matches found and retrieved (depends on your settings)</td> </tr> <tr> <td>"total_found"</td> <td>Total number of found documents matching the query</td> </tr> <tr> <td>"words"</td> <td>An array with words (case-folded and stemmed) as keys and per-word statistics as values</td> </tr> <tr> <td>"error"</td> <td>Query error message reported by searchd</td> </tr> <tr> <td>"warning"</td> <td>Query warning reported by searchd</td> </tr> </tbody> </table> </p> </div> <div class="refsect1 seealso" id="refsect1-sphinxclient.query-seealso"> <h3 class="title">See Also</h3> <p class="para"> <ul class="simplelist"> <li class="member"><a href="sphinxclient.runqueries.html" class="xref">SphinxClient::runQueries</a></li> <li class="member"><a href="sphinxclient.addquery.html" class="xref">SphinxClient::addQuery</a></li> </ul> </p> </div> </div><hr /><div class="manualnavbar" style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="sphinxclient.open.html">SphinxClient::open</a></div> <div class="next" style="text-align: right; float: right;"><a href="sphinxclient.resetfilters.html">SphinxClient::resetFilters</a></div> <div class="up"><a href="class.sphinxclient.html">SphinxClient</a></div> <div class="home"><a href="index.html">PHP Manual</a></div> </div></body></html>