13.9. Multi Term Queries

Multi term queries are intended for a searching for a set of terms.

Each term in a set can be defined as required, prohibited or neither required, nor prohibited (optional).

It means, that if optional terms are added to a query with required terms, then they will have the same result set, but second query will have hits, which match optional terms, moved to the top of result set.

Both of a search method can be used for multi term queries.

Query string:

$hits = $index->find('+word1 author:word2 -word3');
    

or

Query construction by API:

$query = new ZSearchMultiTermQuery();

$query->addTerm(new ZSearchTerm('word1'), true);
$query->addTerm(new ZSearchTerm('word2'), null);
$query->addTerm(new ZSearchTerm('word3'), false);

$hits  = $index->find($query);
    

$signs array contains an information about term type: