Forum und email

SwishSearch->execute

(PECL swish:0.1-0.3.0)

SwishSearch->execute — Execute the search and get the results

Beskrivelse

object SwishSearch->execute ([ string $query ] )
Warning

Denne funktion er EKSPERIMENTABEL. Virkemåden af denne funktion, navnet på funktionen, og andet ellers dokumenteret om denne funktion, ændres muligvis uden advarsel i en fremtidig version af PHP. Brug af denne funktion er på ejet ansvar.

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

Parameterliste

query

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.

Returneringsværdier

Returns SwishResults object.

Errors/Exceptions

Throws SwishException on error.

Eksempler

Example#1 Basic SwishSearch->execute() example

<?php

try {

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

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

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

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

?>

Ovenstående eksempel vil udskrive noget der ligner:

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