/**
* @param InvertedIndex $invertedIndex
* @return arrray
*/
public function queryIndex(InvertedIndex $invertedIndex)
{
$r = $invertedIndex->getDocumentIdsByTerm($this->getQuery()[0]);
if (!empty($r)) {
return [$this->getQuery()[0] => $r];
}
// do partial matches
$terms = array_keys($invertedIndex->getIndex());
$found = [];
foreach ($terms as $term) {
if (Text::contains($term, $this->getQueryString())) {
$found[$term] = $invertedIndex->getDocumentIdsByTerm($term);
}
}
return $found;
}