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).
required which means that documents which do not match this term will not match the query;
prohibited which means that documents which do match this term will not match the query;
neither, in which case matched documents are neither prohibited from nor required to match the term. However, a document must match at least 1 term to match the query.
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: