Swish::prepare

Prepare a search query

&reftitle.description; `object` `Swish::prepare` `string` `query` &warn.experimental.func;

Prepare and return a search object, which you can later use for unlimited number of queries.

&reftitle.parameters;

`query`

- Optional query string. The query can be also set using `SwishSearch::execute` method.

&reftitle.returnvalues;

Returns `SwishSearch` object.

&reftitle.errors;

Throws `SwishException` on error.

&reftitle.examples;

### Basic `Swish::prepare` example

    <?php

    try {

        $swish = new Swish("index.swish-e");
        $search = $swish->prepare("search query");
        $results = $search->execute();
        echo "Found: ", $results->hits, " hits\n";

        $results = $search->execute("new search");

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

    ?>

&example.outputs.similar;

    Found: 2 hits
    Found: 5 hits