/** * Return a list of IDs for the given search criters * * @param string $criteria * @param int $limit * @param int $offset * @return array */ public function get_by_criteria($criteria, $limit, $offset) { $qp = new XapianQueryParser(); $enquire = new XapianEnquire($this->_database); if ($this->get_stem_locale()) { // Note, there may be a problem if this is different than at indexing time! $stemmer = new XapianStem($this->get_stem_locale()); $qp->set_stemmer($stemmer); $qp->set_stemming_strategy(XapianQueryParser::STEM_SOME); } $qp->set_database($this->_database); $query = $qp->parse_query($criteria, XapianQueryParser::FLAG_SPELLING_CORRECTION); $enquire->set_query($query); $this->_spelling = $qp->get_corrected_query_string(); $matches = $enquire->get_mset($offset, $limit); // TODO: get count from $matches->get_matches_estimated() instead of current method $i = $matches->begin(); $ids = array(); while (!$i->equals($matches->end())) { $n = $i->get_rank() + 1; $ids[] = $i->get_document()->get_value(self::XAPIAN_FIELD_ID); $i->next(); } return $ids; }