JavaScript Editor Javascript debugger     Website design 


Execute the search and get the results ()
object SwishSearch->execute ( [string query] )


This function is EXPERIMENTAL. The behaviour of this function, the name of this function, and anything else documented about this function may change without notice in a future release of PHP. Use this function at your own risk.

Searches the index file(s) based on the parameters set in the search object.



The query string is an optional parameter, it can be also set using Swish->prepare() method. The query string is preserved between executions, so you can set it once, but execute the search multiple times.

Return Values

Returns SwishResults object.


Throws SwishException on error.


Example 2516. Basic SwishSearch->execute() example


try {

$swish = new Swish("index.swish-e");
$search = $swish->prepare();

$results = $search->execute("query");
"First query found: ", $results->hits, " hits\n";

$results = $search->execute("new OR query");
"Second query found: ", $results->hits, " hits\n";

} catch (
SwishException $e) {
$e->getMessage(), "\n";


The above example will output something similar to:

First query found: 2 hits
Second query found: 12 hits