public getDocumentIdsByTerm ( string $term ) : array | ||
$term | string | |
리턴 | array |
public function getDocumentIdsByTerm($term)
{
if (!isset($this->index[$term])) {
return [];
}
return $this->index[$term][self::POSTINGS];
}
/** * @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; }