Returned by the percolate() method, the PercolateResultSet object extends the ResultSet by using PercolateResultHit objects as elements instead of ResultHit objects.
The PercolateResultHit object extends ResultHit and offers several additional methods:
getDocSlots()
returns an array that specifies the indexes of documents from the array provided by percolate() that match the current returned query.getDocsMatches($docs)
filters the input document list with the doc slots of the current returned query. The document list must maintain the same indexes as the list provided at percolate().getData()
returns the stored query that is provided.
Returned by the percolateToDocs() method, this object implements Iterator
, similar to the PercolateResultSet. However, the constructor also requires the input document list used at the input of the percolateToDocs() method. The iterated elements are PercolateResultDoc objects.
This is a simple object that holds a document array and an array with matched stored queries as PercolateResultHit objects.
The getData()
method returns the document.
foreach($result as $row) {
$row->getData();
}
The getQueries
method returns the list of stored queries found to have matches for the document. The list can be empty.
// $result is PercolateDocsResultSet
foreach($result as $row) {
// $row is PercolateResultDoc
foreach($row->getQueries as $query) {
// $query is PercolateResultHit
$query->getData();
}
}
The hasQueries
method informs whether the list of stored queries is empty or not.
foreach($result as $row) {
$row->hasQueries();
}